https://github.com/chyroc/detect-ip
https://github.com/chyroc/detect-ip
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chyroc/detect-ip
- Owner: chyroc
- License: apache-2.0
- Created: 2023-02-10T08:21:35.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-18T00:14:24.000Z (almost 3 years ago)
- Last Synced: 2025-01-29T08:23:31.304Z (11 months ago)
- Language: Go
- Size: 19.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# detect-ip
detect-ip is a tool to detect your public ip(v4/v6).
## Install
- *For Cli*
```shell
go install github.com/chyroc/detect-ip/cli/detect-ip@latest
```
- *For Go Package*
```shell
go get github.com/chyroc/detect-ip/detect_ip
```
## Usage
- *For Cli*
```shell
detect-ip
detect-ip -timeout 3000 # timeout 3s
detect-ip -timeout 3000 -json # with json output
detect-ip -timeout 3000 -v4=false # disable ipv4
```
- *For Go Package*
```go
package main
import (
"fmt"
"github.com/chyroc/detect-ip/detect_ip"
)
func main() {
ip := detect_ip.PublicIPV4() // PublicIPV6
// ip := detect_ip.PublicIPV4(detect_ip.WithTimeout(time.Second*3))
fmt.Println(ip)
}
```