You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Licensed under the Apache License, Version 2.0 (the "License");
5
+
* you may not use this file except in compliance with the License.
6
+
* You may obtain a copy of the License at
7
+
*
8
+
* http://www.apache.org/licenses/LICENSE-2.0
9
+
*
10
+
* Unless required by applicable law or agreed to in writing, software
11
+
* distributed under the License is distributed on an "AS IS" BASIS,
12
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+
* See the License for the specific language governing permissions and
14
+
* limitations under the License.
15
+
*/
16
+
17
+
package ips
18
+
19
+
import (
20
+
"github.com/spf13/cobra"
21
+
)
22
+
23
+
funcinit() {
24
+
rootCmd.AddCommand(myipCmd)
25
+
26
+
// myip
27
+
myipCmd.Flags().StringVarP(&localAddr, "local-addr", "", "", "Specify local address for outbound connections.")
28
+
myipCmd.Flags().IntVarP(&myIPCount, "count", "", 0, "Number of detectors to confirm the IP.")
29
+
myipCmd.Flags().IntVarP(&myIPTimeoutS, "timeout", "", 0, "Set the maximum wait time for detectors.")
30
+
31
+
// operate
32
+
myipCmd.Flags().StringVarP(&fields, "fields", "f", "", "Specify the fields of interest for the IP data. Separate multiple fields with commas.")
33
+
myipCmd.Flags().BoolVarP(&useDBFields, "use-db-fields", "", false, "Use field names as they appear in the database. Default is common field names.")
34
+
myipCmd.Flags().StringVarP(&rewriteFiles, "rewrite-files", "r", "", "List of files that need to be rewritten based on the given configurations.")
35
+
myipCmd.Flags().StringVarP(&lang, "lang", "", "", "Set the language for the output. Example values: en, zh-CN, etc.")
36
+
37
+
// database
38
+
myipCmd.Flags().StringVarP(&rootFile, "file", "i", "", "Path to the IPv4 and IPv6 database file.")
39
+
myipCmd.Flags().StringVarP(&rootFormat, "format", "", "", "Specify the format of the database. Examples: ipdb, mmdb, etc.")
40
+
myipCmd.Flags().StringVarP(&rootIPv4File, "ipv4-file", "", "", "Path to the IPv4 database file.")
41
+
myipCmd.Flags().StringVarP(&rootIPv4Format, "ipv4-format", "", "", "Specify the format for IPv4 data. Examples: ipdb, mmdb, etc.")
42
+
myipCmd.Flags().StringVarP(&rootIPv6File, "ipv6-file", "", "", "Path to the IPv6 database file.")
43
+
myipCmd.Flags().StringVarP(&rootIPv6Format, "ipv6-format", "", "", "Specify the format for IPv6 data. Examples: ipdb, mmdb, etc.")
44
+
myipCmd.Flags().StringVarP(&readerOption, "database-option", "", "", "Specify the option for database reader.")
45
+
46
+
// output
47
+
myipCmd.Flags().StringVarP(&rootTextFormat, "text-format", "", "", "Specify the desired format for text output. It supports %origin and %values parameters.")
48
+
myipCmd.Flags().StringVarP(&rootTextValuesSep, "text-values-sep", "", "", "Specify the separator for values in text output. (default is space)")
49
+
myipCmd.Flags().BoolVarP(&rootJson, "json", "j", false, "Output the results in JSON format.")
50
+
myipCmd.Flags().BoolVarP(&rootJsonIndent, "json-indent", "", false, "Output the results in indent JSON format.")
51
+
}
52
+
53
+
varmyipCmd=&cobra.Command{
54
+
Use: "myip",
55
+
Short: "Retrieve your public IP address.",
56
+
Long: `The 'myip' command uses multiple detectors to discover and return your public IP address.
57
+
It is designed to work in scenarios with multiple network interfaces and allows you to specify
58
+
the local address for outbound connections, the number of detectors to confirm the IP, and the timeout
0 commit comments