mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2025-07-06 21:29:25 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
789cc6939e
|
|||
b57beded8f
|
|||
d29e238beb
|
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
make: ["lint", "test"]
|
make: ["lint", "unit-test", "integration-test"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ Take a look at [ifconfig.es](https://ifconfig.es) a live site using `whatismyip`
|
|||||||
|
|
||||||
Get your public IP easily from the command line:
|
Get your public IP easily from the command line:
|
||||||
|
|
||||||
```text
|
```bash
|
||||||
curl ifconfig.es
|
curl ifconfig.es
|
||||||
127.0.0.1
|
127.0.0.1
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ curl -6 ifconfig.es
|
|||||||
|
|
||||||
Get the IP of your DNS provider:
|
Get the IP of your DNS provider:
|
||||||
|
|
||||||
```text
|
```bash
|
||||||
curl -L dns.ifconfig.es
|
curl -L dns.ifconfig.es
|
||||||
2a04:e4c0:47::67 (Spain / OPENDNS)
|
2a04:e4c0:47::67 (Spain / OPENDNS)
|
||||||
```
|
```
|
||||||
@ -134,7 +134,7 @@ Usage of whatismyip:
|
|||||||
-geoip2-city string
|
-geoip2-city string
|
||||||
Path to GeoIP2 city database
|
Path to GeoIP2 city database
|
||||||
-resolver string
|
-resolver string
|
||||||
Path to the resolver configuration. It actually enables the resolver for DNS client discover.
|
Path to the resolver configuration. It actually enables the resolver for DNS client discovery.
|
||||||
-template string
|
-template string
|
||||||
Path to template file
|
Path to template file
|
||||||
-tls-bind string
|
-tls-bind string
|
||||||
|
@ -70,7 +70,7 @@ func Setup(args []string) (output string, err error) {
|
|||||||
&resolverConf,
|
&resolverConf,
|
||||||
"resolver",
|
"resolver",
|
||||||
"",
|
"",
|
||||||
"Path to the resolver configuration. It actually enables the resolver for DNS client discover.")
|
"Path to the resolver configuration. It actually enables the resolver for DNS client discovery.")
|
||||||
flags.StringVar(
|
flags.StringVar(
|
||||||
&App.BindAddress,
|
&App.BindAddress,
|
||||||
"bind",
|
"bind",
|
||||||
|
@ -31,7 +31,7 @@ func GetDNSDiscoveryHandler(store *cache.Cache, domain string, redirectPort stri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Request.Host == domain {
|
if ctx.Request.Host == domain && ctx.Request.URL.Path == "/" {
|
||||||
ctx.Redirect(http.StatusFound, fmt.Sprintf("http://%s.%s%s", uuid.New().String(), domain, redirectPort))
|
ctx.Redirect(http.StatusFound, fmt.Sprintf("http://%s.%s%s", uuid.New().String(), domain, redirectPort))
|
||||||
ctx.Abort()
|
ctx.Abort()
|
||||||
return
|
return
|
||||||
|
@ -33,6 +33,19 @@ func TestGetDNSDiscoveryHandler(t *testing.T) {
|
|||||||
assert.Equal(t, testIP.ipv4+"\n", w.Body.String())
|
assert.Equal(t, testIP.ipv4+"\n", w.Body.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("return 404 if there is a path", func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/path", nil)
|
||||||
|
req.Host = domain
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
handler(c)
|
||||||
|
app.ServeHTTP(w, req)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("redirects if host is domain", func(t *testing.T) {
|
t.Run("redirects if host is domain", func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "/", nil)
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
req.Host = domain
|
req.Host = domain
|
||||||
|
Reference in New Issue
Block a user