Skip to content

Integrate bitmask-core/implement v5 #758

Pea Nut requested to merge v5-integration-seperated into main

not yet fully ready to review - but just smaller changes needed - depend on other repos

This MR also has some other smaller fixes. The big change is the v5 implementation. This MR replaces this one !172 (closed) (the ultra big one with all changes, including improve-logging/error handling).

To check it out, you need a running menshen instance: (it's a bit complicated - so I will wait until things are fixed/merged in menshen and update this)

To run the tests, use

API_URL=http://localhost:8443 go test -count=1 -v ./...

I added comments in the code which help understand how/why things are.

Env variables

  • use env API_VERSION=5 to enforce v5 code path
  • use env API_URL="http://localhost:8443" to change menshen instance
  • both default values (version and url) are part of the providres.json
  • There is an open todo/issue to document all environment variables

In pkg/bitmask/vpn_control.go:startOpenVPN, I do not use udp/53 (makes problems, issue is linked there).

Some implementation details:

GetBestLocation

  • for each gateway we get from menshen: calculate rtt
  • for each gateway in a locatoin, calc the avg rtt for all gateways
  • normalize value (between 0 and 1)
  • I wrote a simple rtt-calculation-functionn - please read the comments in the code

GetBestGateways

  • for each Gateway, just shuffle gateways and use the first n

There are some open future TODOs on the menshen side (no blocker for this MR)

  • Each gateway needs an identifier and a display name. Needs to be fixed in menshen, then remove all the strings.Title calls
  • support for CountryCode (filtering and a field in the gateway)
  • to discuss: cache client certificate
  • needs load metric
Edited by Pea Nut

Merge request reports