github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/config/flags_policy.go (about) 1 /* 2 * Copyright (C) 2020 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 "time" 22 23 "github.com/mysteriumnetwork/node/metadata" 24 "github.com/urfave/cli/v2" 25 ) 26 27 var ( 28 // FlagAccessPolicyAddress Trust oracle URL for retrieving access policies. 29 FlagAccessPolicyAddress = cli.StringFlag{ 30 Name: metadata.FlagNames.AccessPolicyOracleAddress, 31 Usage: "URL of trust oracle endpoint for retrieving lists of access policies", 32 Value: metadata.DefaultNetwork.AccessPolicyOracleAddress, 33 } 34 // FlagAccessPolicyFetchInterval policy list fetch interval. 35 FlagAccessPolicyFetchInterval = cli.DurationFlag{ 36 Name: "access-policy.fetch", 37 Usage: `Proposal fetch interval { "30s", "3m", "1h20m30s" }`, 38 Value: 10 * time.Minute, 39 } 40 // FlagAccessPolicyFetchingEnabled policy list fetch enable 41 FlagAccessPolicyFetchingEnabled = cli.BoolFlag{ 42 Name: "access-policy.fetching-enabled", 43 Usage: "Enable periodic fetching of access policies and saving to memory (allows support for whitelist types other than identity)", 44 Value: false, 45 } 46 ) 47 48 // RegisterFlagsPolicy function registers Policy Oracle flags to flag list. 49 func RegisterFlagsPolicy(flags *[]cli.Flag) { 50 *flags = append(*flags, 51 &FlagAccessPolicyAddress, 52 &FlagAccessPolicyFetchInterval, 53 &FlagAccessPolicyFetchingEnabled, 54 ) 55 } 56 57 // ParseFlagsPolicy function fills in PolicyOracle options from CLI context. 58 func ParseFlagsPolicy(ctx *cli.Context) { 59 Current.ParseStringFlag(ctx, FlagAccessPolicyAddress) 60 Current.ParseDurationFlag(ctx, FlagAccessPolicyFetchInterval) 61 Current.ParseBoolFlag(ctx, FlagAccessPolicyFetchingEnabled) 62 }