github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_service_openvpn.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 // FlagOpenvpnProtocol protocol for OpenVPN to use. 26 FlagOpenvpnProtocol = cli.StringFlag{ 27 Name: "openvpn.proto", 28 Usage: "OpenVPN protocol to use. Options: { udp, tcp }", 29 Value: "udp", 30 } 31 // FlagOpenvpnPort port for OpenVPN to use. 32 FlagOpenvpnPort = cli.IntFlag{ 33 Name: "openvpn.port", 34 Usage: "OpenVPN port to use. If not specified, random port will be used", 35 Value: 0, 36 } 37 // FlagOpenvpnSubnet OpenVPN subnet that will be used for connecting clients. 38 FlagOpenvpnSubnet = cli.StringFlag{ 39 Name: "openvpn.subnet", 40 Usage: "OpenVPN subnet that will be used to connecting VPN clients", 41 Value: "10.8.0.0", 42 } 43 // FlagOpenvpnNetmask OpenVPN subnet netmask. 44 FlagOpenvpnNetmask = cli.StringFlag{ 45 Name: "openvpn.netmask", 46 Usage: "OpenVPN subnet netmask", 47 Value: "255.255.255.0", 48 } 49 // FlagOpenVPNAccessPolicies a comma-separated list of access policies that determines allowed identities to use the service. 50 FlagOpenVPNAccessPolicies = cli.StringFlag{ 51 Name: "openvpn.access-policies", 52 Usage: "Comma separated list that determines the access policies of the OpenVPN service.", 53 } 54 ) 55 56 // RegisterFlagsServiceOpenvpn registers OpenVPN CLI flags for parsing them later 57 func RegisterFlagsServiceOpenvpn(flags *[]cli.Flag) { 58 *flags = append(*flags, 59 &FlagOpenvpnProtocol, 60 &FlagOpenvpnPort, 61 &FlagOpenvpnSubnet, 62 &FlagOpenvpnNetmask, 63 &FlagOpenVPNAccessPolicies, 64 ) 65 } 66 67 // ParseFlagsServiceOpenvpn parses CLI flags and registers value to configuration 68 func ParseFlagsServiceOpenvpn(ctx *cli.Context) { 69 Current.ParseStringFlag(ctx, FlagOpenvpnProtocol) 70 Current.ParseIntFlag(ctx, FlagOpenvpnPort) 71 Current.ParseStringFlag(ctx, FlagOpenvpnSubnet) 72 Current.ParseStringFlag(ctx, FlagOpenvpnNetmask) 73 Current.ParseStringFlag(ctx, FlagOpenVPNAccessPolicies) 74 }