Commit 20fa8550 authored by meskio's avatar meskio

[feat] use the API IP instead of the domain

In some countries riseup VPN is block by IP address, we can avoid this
blockage by pinning the IP address in the client.

- Resolves: #175
parent 52efef43
Pipeline #29374 passed with stages
in 34 minutes and 16 seconds
......@@ -11,6 +11,7 @@ binaryName = riseup-vpn
providerURL = riseup.net
apiURL = https://api.black.riseup.net/
apiIP = 198.252.153.107
caURL = https://black.riseup.net/ca.crt
infoURL = https://riseup.net/vpn
......@@ -31,6 +32,7 @@ binaryName = calyx-vpn
providerURL = https://calyx.net
apiURL = https://api.calyx.net:4430/
apiIP = 162.247.73.194
caURL = https://calyx.net/ca.crt
infoURL = https://calyx.net/
......@@ -50,6 +52,7 @@ binaryName = demo-vpn
providerURL = pt.demo.bitmask.net
apiURL = https://pt.demo.bitmask.net:8000/
apiIP = 198.252.153.85
caURL = https://pt.demo.bitmask.net:8000/ca.crt
infoURL = https://bitmask.net
......
......@@ -20,7 +20,7 @@ def getProviderData(provider, config):
keys = ('name', 'applicationName', 'binaryName',
'providerURL', 'tosURL', 'helpURL',
'askForDonations', 'donateURL', 'apiURL',
'askForDonations', 'donateURL', 'apiURL', 'apiIP',
'geolocationAPI', 'caCertString')
for value in keys:
......
......@@ -15,6 +15,7 @@ const (
HelpURL = "$helpURL"
TosURL = "$tosURL"
APIURL = "$apiURL"
APIIP = "$apiIP"
GeolocationAPI = "$geolocationAPI"
)
......
// Code generated by go generate; DO NOT EDIT.
// This file was generated by vendorize.py
// At 2019-10-11 16:05:25
// At 2019-11-06 20:16:20
package config
......@@ -15,6 +15,7 @@ const (
HelpURL = "https://riseup.net/support"
TosURL = "https://riseup.net/tos"
APIURL = "https://api.black.riseup.net/"
APIIP = "198.252.153.107"
GeolocationAPI = "https://api.black.riseup.net:9001/json"
)
......
......@@ -16,6 +16,7 @@
package bonafide
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
......@@ -23,7 +24,9 @@ import (
"io"
"io/ioutil"
"log"
"net"
"net/http"
"strings"
"time"
"0xacab.org/leap/bitmask-vpn/pkg/config"
......@@ -66,6 +69,17 @@ type geoLocation struct {
SortedGateways []string `json:"gateways"`
}
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
dialer := net.Dialer{}
port := strings.Split(addr, ":")[1]
conn, err := dialer.DialContext(ctx, network, config.APIIP+":"+port)
if err != nil {
log.Printf("Can't dial directly to the provider IP addr (%s): %v", config.APIIP, err)
return dialer.DialContext(ctx, network, addr)
}
return conn, err
}
func New() *Bonafide {
certs := x509.NewCertPool()
certs.AppendCertsFromPEM(config.CaCert)
......@@ -74,6 +88,7 @@ func New() *Bonafide {
TLSClientConfig: &tls.Config{
RootCAs: certs,
},
DialContext: dialContext,
},
}
_, tzOffsetSeconds := time.Now().Zone()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment