Skip to content

Commit

Permalink
fixed configure's outbound port behavior (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aptimex authored Aug 6, 2024
1 parent b8825f9 commit c6ff7b9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ 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().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.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 @@ -175,15 +175,28 @@ func (c configureCmdConfig) Run() {
}

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

err = serverConfigRelay.SetPort(Port)
// 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(serverPort)
check("failed to set port", err)


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

0 comments on commit c6ff7b9

Please sign in to comment.