github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_service_wireguard.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package config
    19  
    20  import (
    21  	"github.com/urfave/cli/v2"
    22  )
    23  
    24  var (
    25  	// FlagWireguardListenPorts range of listen ports.
    26  	// TODO: remove the deprecated flag once all users stop to use it.
    27  	FlagWireguardListenPorts = cli.StringFlag{
    28  		Name:  "wireguard.listen.ports",
    29  		Usage: "Deprecated flag, use --udp.ports to set range of listen ports",
    30  		Value: "0:0",
    31  	}
    32  	// FlagWireguardListenSubnet subnet to be used by the wireguard service.
    33  	FlagWireguardListenSubnet = cli.StringFlag{
    34  		Name:  "wireguard.allowed.subnet",
    35  		Usage: "Subnet to be used by the wireguard service",
    36  		Value: "10.182.0.0/16",
    37  	}
    38  	// FlagWireguardAccessPolicies a comma-separated list of access policies that determines allowed identities to use the service.
    39  	FlagWireguardAccessPolicies = cli.StringFlag{
    40  		Name:  "wireguard.access-policies",
    41  		Usage: "Comma separated list that determines the access policies of the wireguard service.",
    42  	}
    43  )
    44  
    45  // RegisterFlagsServiceWireguard function register Wireguard flags to flag list
    46  func RegisterFlagsServiceWireguard(flags *[]cli.Flag) {
    47  	*flags = append(*flags,
    48  		&FlagWireguardListenPorts,
    49  		&FlagWireguardListenSubnet,
    50  		&FlagWireguardAccessPolicies,
    51  	)
    52  }
    53  
    54  // ParseFlagsServiceWireguard parses CLI flags and registers value to configuration
    55  func ParseFlagsServiceWireguard(ctx *cli.Context) {
    56  	Current.ParseStringFlag(ctx, FlagWireguardListenPorts)
    57  	Current.ParseStringFlag(ctx, FlagWireguardListenSubnet)
    58  	Current.ParseStringFlag(ctx, FlagWireguardAccessPolicies)
    59  }