github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_location.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 "fmt" 22 23 "github.com/mysteriumnetwork/node/metadata" 24 "github.com/urfave/cli/v2" 25 ) 26 27 var ( 28 // FlagIPDetectorURL URL of IP detection service. 29 FlagIPDetectorURL = cli.StringFlag{ 30 Name: "ip-detector", 31 Usage: "Address (URL form) of IP detection service", 32 Value: metadata.DefaultNetwork.LocationAddress, 33 } 34 // FlagLocationType location detector type. 35 FlagLocationType = cli.StringFlag{ 36 Name: "location.type", 37 Usage: "Location autodetect adapter. Options: { oracle, builtin, mmdb, manual }", 38 Value: "oracle", 39 } 40 // FlagLocationAddress URL of location detector. 41 FlagLocationAddress = cli.StringFlag{ 42 Name: metadata.FlagNames.LocationAddress, 43 Usage: fmt.Sprintf( 44 "Address of specific location adapter given in '--%s'", 45 FlagLocationType.Name, 46 ), 47 Value: metadata.DefaultNetwork.LocationAddress, 48 } 49 // FlagLocationCountry service location country. 50 FlagLocationCountry = cli.StringFlag{ 51 Name: "location.country", 52 Usage: "Service location country", 53 } 54 // FlagLocationCity service location city. 55 FlagLocationCity = cli.StringFlag{ 56 Name: "location.city", 57 Usage: "Service location city", 58 } 59 // FlagLocationIPType service location node type. 60 FlagLocationIPType = cli.StringFlag{ 61 Name: "location.ip-type", 62 Usage: "Service location IP type (residential, datacenter, etc.)", 63 } 64 ) 65 66 // RegisterFlagsLocation function registers location flags to flag list. 67 func RegisterFlagsLocation(flags *[]cli.Flag) { 68 *flags = append(*flags, 69 &FlagIPDetectorURL, 70 &FlagLocationType, 71 &FlagLocationAddress, 72 &FlagLocationCountry, 73 &FlagLocationCity, 74 &FlagLocationIPType, 75 ) 76 } 77 78 // ParseFlagsLocation function fills in location options from CLI context. 79 func ParseFlagsLocation(ctx *cli.Context) { 80 Current.ParseStringFlag(ctx, FlagIPDetectorURL) 81 Current.ParseStringFlag(ctx, FlagLocationType) 82 Current.ParseStringFlag(ctx, FlagLocationAddress) 83 Current.ParseStringFlag(ctx, FlagLocationCountry) 84 Current.ParseStringFlag(ctx, FlagLocationCity) 85 Current.ParseStringFlag(ctx, FlagLocationIPType) 86 }