diff --git a/README.md b/README.md index 1951b30..690e418 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Then run `make client` or `make server`. Output binary will be in `build` folder ## Setup ### For the administrator of the server -0. Set up the underlying proxy server. Note that if you are using OpenVPN, you must change the protocol to TCP as Cloak does not support UDP +0. Set up the underlying proxy server. 1. Download [the latest release](https://github.com/cbeuw/Cloak/releases) or clone and build this repo. 2. Run ck-server -k. The base64 string before the comma is the **public** key to be given to users, the one after the comma is the **private** key to be kept secret 3. Run `ck-server -u`. This will be used as the AdminUID diff --git a/internal/client/state.go b/internal/client/state.go index 4ecd27b..e663a49 100644 --- a/internal/client/state.go +++ b/internal/client/state.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "io/ioutil" + "strconv" "strings" "time" @@ -23,6 +24,7 @@ type rawConfig struct { Transport string NumConn int StreamTimeout int + RemotePort int } // State stores the parsed configuration fields @@ -142,5 +144,15 @@ func (sta *State) ParseConfig(conf string) (err error) { } sta.staticPub = pub + // OPTIONAL: set RemotePort via JSON + // if RemotePort is specified in the JSON we overwrite sta.RemotePort + // if not, don't do anything, since sta.RemotePort is already initialised in ck-client.go + if preParse.RemotePort != 0 { + // basic validity check + if preParse.RemotePort >= 1 && preParse.RemotePort <= 65535 { + sta.RemotePort = strconv.Itoa(preParse.RemotePort) + } + } + return nil }