Fix issue with replying with port
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
main.exe
|
||||
8
main.go
8
main.go
@@ -4,8 +4,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var Error *log.Logger
|
||||
@@ -26,7 +27,10 @@ func init() {
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, r.RemoteAddr)
|
||||
fullIP := r.RemoteAddr
|
||||
parts := strings.Split(fullIP, ":")
|
||||
ip := parts[0]
|
||||
fmt.Fprintf(w, ip)
|
||||
})
|
||||
|
||||
http.ListenAndServe(":8080", nil)
|
||||
|
||||
Reference in New Issue
Block a user