Skip to content

Commit

Permalink
Merge branch 'main' into server-nicknames
Browse files Browse the repository at this point in the history
  • Loading branch information
Aptimex authored Aug 6, 2024
2 parents fe22fec + c6ff7b9 commit 960486e
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func init() {

configureCmd.Flags().StringSliceVarP(&configureCmdArgs.allowedIPs, "routes", "r", configureCmdArgs.allowedIPs, "[REQUIRED] CIDR IP ranges that will be routed through wiretap (example \"10.0.0.1/24\")")
configureCmd.Flags().StringVarP(&configureCmdArgs.endpoint, "endpoint", "e", configureCmdArgs.endpoint, "[REQUIRED] IP:PORT (or [IP]:PORT for IPv6) of wireguard listener that server will connect to (example \"1.2.3.4:51820\")")
configureCmd.Flags().BoolVar(&configureCmdArgs.outbound, "outbound", configureCmdArgs.outbound, "client will initiate handshake to server; --endpoint now specifies server's listening socket instead of client's")
configureCmd.Flags().IntVarP(&configureCmdArgs.port, "port", "p", configureCmdArgs.port, "listener port for local wireguard relay; default is to use the same port specified by --endpoint")
configureCmd.Flags().StringVarP(&configureCmdArgs.nickname, "nickname", "n", configureCmdArgs.nickname, "Server nickname to display in 'status' command")
configureCmd.Flags().BoolVar(&configureCmdArgs.outbound, "outbound", configureCmdArgs.outbound, "client will initiate handshake to server; --endpoint now specifies server's listening socket instead of client's, and --port assigns the server's listening port instead of client's")
configureCmd.Flags().IntVarP(&configureCmdArgs.port, "port", "p", configureCmdArgs.port, "listener port for wireguard relay. Default is to copy the --endpoint port. If --outbound, sets port for the server; else for the client.")
configureCmd.Flags().StringVarP(&configureCmdArgs.nickname, "nickname", "n", configureCmdArgs.nickname, "Server nickname to display in 'status' command")
configureCmd.Flags().StringVarP(&configureCmdArgs.configFileRelay, "relay-output", "", configureCmdArgs.configFileRelay, "wireguard relay config output filename")
configureCmd.Flags().StringVarP(&configureCmdArgs.configFileE2EE, "e2ee-output", "", configureCmdArgs.configFileE2EE, "wireguard E2EE config output filename")
configureCmd.Flags().StringVarP(&configureCmdArgs.configFileServer, "server-output", "s", configureCmdArgs.configFileServer, "wiretap server config output filename")
Expand Down Expand Up @@ -179,18 +179,31 @@ func (c configureCmdConfig) Run() {
}

if c.port == USE_ENDPOINT_PORT {
c.port = portFromEndpoint(c.endpoint);
c.port = portFromEndpoint(c.endpoint)
}

// We only configure one of these (based on --outbound or not)
// The other must be manually changed in the configs/command/envs
var clientPort int;
var serverPort int;

if c.outbound {
clientPort = Port
serverPort = c.port
} else {
clientPort = c.port
serverPort = Port
}

err = serverConfigRelay.SetPort(Port)
err = serverConfigRelay.SetPort(serverPort)
check("failed to set port", err)

err = serverConfigRelay.SetNickname(c.nickname)
check("failed to set nickname", err)


clientConfigRelayArgs := peer.ConfigArgs{
ListenPort: c.port,
ListenPort: clientPort,
Peers: []peer.PeerConfigArgs{
{
PublicKey: serverConfigRelay.GetPublicKey(),
Expand Down

0 comments on commit 960486e

Please sign in to comment.