|
@@ -1,7 +1,6 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "errors"
|
|
|
"io/ioutil"
|
|
|
"net"
|
|
|
"net/http"
|
|
@@ -50,21 +49,22 @@ func getCurrentAbPathByExecutable() string {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
-func getClientIp() (string, error) {
|
|
|
+func getClientIp() {
|
|
|
addrs, err := net.InterfaceAddrs()
|
|
|
|
|
|
if err != nil {
|
|
|
- return "", err
|
|
|
+ log.Errorf("Error getClientIp %v", err)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
for _, address := range addrs {
|
|
|
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
|
|
if ipnet.IP.To4() != nil {
|
|
|
- return ipnet.IP.String(), nil
|
|
|
+ //return ipnet.IP.String(), nil
|
|
|
+ log.Infof("HTTP://" + ipnet.IP.String() + ":" + port)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return "", errors.New("Can not find the client ip address!")
|
|
|
}
|
|
|
|
|
|
func walkDir(filestr string) ([]string, error) {
|
|
@@ -264,12 +264,7 @@ func getFiles(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func doWork() {
|
|
|
- ip, err := getClientIp()
|
|
|
- if err != nil {
|
|
|
- log.Errorf("Error getClientIp %v", err)
|
|
|
- return
|
|
|
- }
|
|
|
- log.Infof("HTTP://" + ip + ":" + port)
|
|
|
+ getClientIp()
|
|
|
|
|
|
r := gin.Default()
|
|
|
//加载静态文件
|