Skip to content

Commit

Permalink
Add DNS to TUN, in VPN-Client (#1381)
Browse files Browse the repository at this point in the history
* get --dns value from config

* set DNS on TUN if value in config be valid [On Linux]

* add RevertDNS on closeTUN()

* modify app[PUT] endpoint to get --dns value

* set DNS on TUN if value in config be valid [On Darwin]

* set DNS on TUN if value in config be valid [On Windows]

* set dns during generate config

* DNS config for the VPN UI

* DNS config for the VPN in the manager

* fix settingForm type

* make build-ui

* go get dmsg@develop and skywire-utilities@develop

* update dmsg@develop

* update dmsg@develop

* update dmsg@develop

* build ui
  • Loading branch information
mrpalide authored Dec 14, 2022
1 parent 7e2b044 commit a3d6630
Show file tree
Hide file tree
Showing 43 changed files with 532 additions and 61 deletions.
14 changes: 14 additions & 0 deletions cmd/apps/vpn-client/vpn-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
localSKStr = flag.String("sk", "", "Local SecKey")
passcode = flag.String("passcode", "", "Passcode to authenticate connection")
killswitch = flag.Bool("killswitch", false, "If set, the Internet won't be restored during reconnection attempts")
dnsAddr = flag.String("dns", "", "address of DNS want set to tun")
)

func main() {
Expand Down Expand Up @@ -107,13 +108,26 @@ func main() {
}
}

var dnsAddress string
if *dnsAddr != "" {
dnsIP := parseIP(*dnsAddr)
if dnsIP == nil {
fmt.Println("Invalid DNS Address value. VPN will use current machine DNS.")
dnsAddress = ""
} else {
dnsAddress = dnsIP.String()
}
}

setAppPort(appCl, appCl.Config().RoutingPort)

fmt.Printf("Connecting to VPN server %s\n", serverPK.String())

vpnClientCfg := vpn.ClientConfig{
Passcode: *passcode,
Killswitch: *killswitch,
ServerPK: serverPK,
DNSAddr: dnsAddress,
}

vpnClient, err := vpn.NewClient(vpnClientCfg, appCl)
Expand Down
1 change: 0 additions & 1 deletion cmd/skywire-visor/static/268.575055e245c2f30e.js

This file was deleted.

1 change: 1 addition & 0 deletions cmd/skywire-visor/static/268.ae9df91b0827192d.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cmd/skywire-visor/static/502.84c2703d9d6cfa34.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cmd/skywire-visor/static/502.e715733024006b44.js

This file was deleted.

1 change: 1 addition & 0 deletions cmd/skywire-visor/static/974.0b8f8799aa1f6537.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cmd/skywire-visor/static/974.cbcda0695ddb168b.js

This file was deleted.

12 changes: 12 additions & 0 deletions cmd/skywire-visor/static/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@
"no-history": "This tab will show the last {{ number }} public keys used.",
"default-note-warning": "The default note has been used.",
"pagination-info": "{{ currentElementsRange }} of {{ totalElements }}",
"dns": "Custom DNS server IP address",
"dns-error": "Invalid value.",
"killswitch-check": "Activate killswitch",
"killswitch-info": "When active, all network connections will be disabled if the app is running but the VPN protection is interrupted (for temporary errors or any other problem). This avoids data leaks.",
"settings-changed-alert": " The changes have not been saved yet.",
Expand Down Expand Up @@ -890,6 +892,9 @@
"data-units-info": "Allows to select the units that will be used to display the data transmission statistics.",
"minimum-hops": "Minimum hops",
"minimum-hops-info": "Allows to set the minimum number of hops the connections must pass through other Skywire visors before reaching the final destination.",
"dns": "Custom DNS server",
"dns-info": "Allows to use a custom DNS server, which could improve privacy and prevent sites from being blocked by the default DNS server of your ISP.",
"setting-none": "None",
"setting-on": "On",
"setting-off": "Off",
"working-warning": "The system is busy. Please wait for the previous operation to finish.",
Expand All @@ -901,6 +906,13 @@
"only-bytes": "Bytes for all stats",
"bits-speed-and-bytes-volume": "Bits for speed and bytes for volume (default)"
}
},

"dns-config": {
"title": "Custom DNS server",
"ip": "Custom DNS server IP address",
"save-config-button": "Save configuration",
"done": "Changes saved."
}
}
}
12 changes: 12 additions & 0 deletions cmd/skywire-visor/static/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@
"no-history": "Esta pestaña mostrará las últimas {{ number }} llaves públicas usadas.",
"default-note-warning": "La nota por defecto ha sido utilizada.",
"pagination-info": "{{ currentElementsRange }} de {{ totalElements }}",
"dns": "Dirección IP del servidor DNS personalizado",
"dns-error": "Valor inválido.",
"killswitch-check": "Activar killswitch",
"killswitch-info": "Cuando está activo, todas las conexiones de red se desactivarán si la aplicación se está ejecutando pero la protección VPN está interrumpida (por errores temporales o cualquier otro problema). Esto evita fugas de datos.",
"settings-changed-alert": "Los cambios aún no se han guardado.",
Expand Down Expand Up @@ -894,6 +896,9 @@
"data-units-info": "Permite seleccionar las unidades que se utilizarán para mostrar las estadísticas de transmisión de datos.",
"minimum-hops": "Saltos mínimos",
"minimum-hops-info": "Permite configurar la cantidad mínima de saltos que la conexión deberá realizar a través de otros visores de Skywire antes de alcanzar el destino final.",
"dns": "Servidor DNS personalizado",
"dns-info": "Permite usar un servidor DNS personalizado, lo que podría mejorar la privacidad y prevenir que algunos sitios sean bloqueados por el servidor DNS por defecto de su proveedor.",
"setting-none": "Ninguno",
"setting-on": "Encendido",
"setting-off": "Apagado",
"working-warning": "El sistema está ocupado. Por favor, espere a que finalice la operación anterior.",
Expand All @@ -905,6 +910,13 @@
"only-bytes": "Bytes para todas las estadísticas",
"bits-speed-and-bytes-volume": "Bits para velocidad y bytes para volumen (predeterminado)"
}
},

"dns-config": {
"title": "Servidor DNS personalizado",
"ip": "Dirección IP del servidor DNS personalizado",
"save-config-button": "Guardar configuración",
"done": "Cambios guardados."
}
}
}
12 changes: 12 additions & 0 deletions cmd/skywire-visor/static/assets/i18n/es_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@
"no-history": "This tab will show the last {{ number }} public keys used.",
"default-note-warning": "The default note has been used.",
"pagination-info": "{{ currentElementsRange }} of {{ totalElements }}",
"dns": "Custom DNS server IP address",
"dns-error": "Invalid value.",
"killswitch-check": "Activate killswitch",
"killswitch-info": "When active, all network connections will be disabled if the app is running but the VPN protection is interrupted (for temporary errors or any other problem). This avoids data leaks.",
"settings-changed-alert": " The changes have not been saved yet.",
Expand Down Expand Up @@ -894,6 +896,9 @@
"data-units-info": "Allows to select the units that will be used to display the data transmission statistics.",
"minimum-hops": "Minimum hops",
"minimum-hops-info": "Allows to set the minimum number of hops the connections must pass through other Skywire visors before reaching the final destination.",
"dns": "Custom DNS server",
"dns-info": "Allows to use a custom DNS server, which could improve privacy and prevent sites from being blocked by the default DNS server of your ISP.",
"setting-none": "None",
"setting-on": "On",
"setting-off": "Off",
"working-warning": "The system is busy. Please wait for the previous operation to finish.",
Expand All @@ -905,6 +910,13 @@
"only-bytes": "Bytes for all stats",
"bits-speed-and-bytes-volume": "Bits for speed and bytes for volume (default)"
}
},

"dns-config": {
"title": "Custom DNS server",
"ip": "Custom DNS server IP address",
"save-config-button": "Save configuration",
"done": "Changes saved."
}
}
}
4 changes: 2 additions & 2 deletions cmd/skywire-visor/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#0072FF">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<style>@charset "UTF-8";@font-face{font-family:Skycoin;font-style:normal;font-weight:300;src:url(/assets/fonts/skycoin/skycoin-light-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-light-webfont.woff) format("woff")}@font-face{font-family:Skycoin;font-style:normal;font-weight:400;src:url(/assets/fonts/skycoin/skycoin-regular-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-regular-webfont.woff) format("woff")}@font-face{font-family:Skycoin;font-style:normal;font-weight:700;src:url(/assets/fonts/skycoin/skycoin-bold-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-bold-webfont.woff) format("woff")}.app-background{width:100%;height:100%;top:0;left:0;position:fixed;background:linear-gradient(#060a10,#0a1421) no-repeat fixed!important;box-shadow:inset 0 0 200px #608dcd40;z-index:-1}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(32,34,38,0)}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#f8f9f9}html{box-sizing:border-box;-ms-overflow-style:scrollbar}*,*:before,*:after{box-sizing:inherit}html,body{height:100%;min-height:100%;font-family:Skycoin;margin:0;color:#f8f9f9!important;font-size:1rem;-webkit-backface-visibility:hidden;backface-visibility:hidden}</style><link rel="stylesheet" href="styles.7b510655c4f90452.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.7b510655c4f90452.css"></noscript></head>
<style>@charset "UTF-8";@font-face{font-family:Skycoin;font-style:normal;font-weight:300;src:url(/assets/fonts/skycoin/skycoin-light-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-light-webfont.woff) format("woff")}@font-face{font-family:Skycoin;font-style:normal;font-weight:400;src:url(/assets/fonts/skycoin/skycoin-regular-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-regular-webfont.woff) format("woff")}@font-face{font-family:Skycoin;font-style:normal;font-weight:700;src:url(/assets/fonts/skycoin/skycoin-bold-webfont.woff2) format("woff2"),url(/assets/fonts/skycoin/skycoin-bold-webfont.woff) format("woff")}.app-background{width:100%;height:100%;top:0;left:0;position:fixed;background:linear-gradient(#060a10,#0a1421) no-repeat fixed!important;box-shadow:inset 0 0 200px #608dcd40;z-index:-1}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(32,34,38,0)}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#f8f9f9}html{box-sizing:border-box;-ms-overflow-style:scrollbar}*,*:before,*:after{box-sizing:inherit}html,body{height:100%;min-height:100%;font-family:Skycoin;margin:0;color:#f8f9f9!important;font-size:1rem;-webkit-backface-visibility:hidden;backface-visibility:hidden}</style><link rel="stylesheet" href="styles.6f1fcf3ee7ebda7a.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.6f1fcf3ee7ebda7a.css"></noscript></head>
<body>
<div class="app-background"></div>
<app-root></app-root>
<script src="runtime.a5c78662c56a0f1b.js" type="module"></script><script src="polyfills.30bbe27e0ff95dbc.js" type="module"></script><script src="scripts.b072fe148dd68f99.js" defer></script><script src="main.262c519af02a832f.js" type="module"></script>
<script src="runtime.0741233c8e1f66ed.js" type="module"></script><script src="polyfills.30bbe27e0ff95dbc.js" type="module"></script><script src="scripts.b072fe148dd68f99.js" defer></script><script src="main.af6c017457be1a20.js" type="module"></script>

</body></html>
1 change: 0 additions & 1 deletion cmd/skywire-visor/static/main.262c519af02a832f.js

This file was deleted.

1 change: 1 addition & 0 deletions cmd/skywire-visor/static/main.af6c017457be1a20.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions cmd/skywire-visor/static/styles.6f1fcf3ee7ebda7a.css

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions cmd/skywire-visor/static/styles.7b510655c4f90452.css

This file was deleted.

2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,6 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82 h1:AOjOMys6Ew+IkUHf0lIuaoW42cxQ7JUuq8J5A0mbloI=
github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82/go.mod h1:ykPIRMpkSLssjwNKJpD/DF+F2NVTA/7Ja59gfOSDoh0=
github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123 h1:yCZem366UX05jbiVoe4dKXYU+NRxZbnJjRu1CcNZBXg=
github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123/go.mod h1:ykPIRMpkSLssjwNKJpD/DF+F2NVTA/7Ja59gfOSDoh0=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA=
Expand Down
4 changes: 4 additions & 0 deletions internal/vpn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type Client struct {
tunCreated bool

connectedDuration int64

defaultSystemDNS string //nolint
}

// NewClient creates VPN client instance.
Expand Down Expand Up @@ -324,6 +326,8 @@ func (c *Client) closeTUN() error {

c.tunCreated = false

c.RevertDNS()

return c.tun.Close()
}

Expand Down
1 change: 1 addition & 0 deletions internal/vpn/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ type ClientConfig struct {
Passcode string
Killswitch bool
ServerPK cipher.PubKey
DNSAddr string
}
Loading

0 comments on commit a3d6630

Please sign in to comment.