Browse Source

Merge branch 'master' into support_ssd_volume

pull/1794/head
Chris Lu 4 years ago
parent
commit
bf5873022d
  1. 4
      docker/local-registry-compose.yml
  2. 2
      weed/server/master_server.go
  3. 20
      weed/util/network.go

4
docker/local-registry-compose.yml

@ -13,10 +13,6 @@ services:
- 8080:8080 - 8080:8080
- 18080:18080 - 18080:18080
command: "volume -mserver=master:9333 -port=8080 -ip=volume -max=0 -preStopSeconds=1" command: "volume -mserver=master:9333 -port=8080 -ip=volume -max=0 -preStopSeconds=1"
volumes:
- type: bind
source: /Volumes/mobile_disk/data
target: /data
depends_on: depends_on:
- master - master
filer: filer:

2
weed/server/master_server.go

@ -108,10 +108,10 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers []string) *Maste
ms.guard = security.NewGuard(ms.option.WhiteList, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec) ms.guard = security.NewGuard(ms.option.WhiteList, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec)
if !ms.option.DisableHttp {
handleStaticResources2(r) handleStaticResources2(r)
r.HandleFunc("/", ms.proxyToLeader(ms.uiStatusHandler)) r.HandleFunc("/", ms.proxyToLeader(ms.uiStatusHandler))
r.HandleFunc("/ui/index.html", ms.uiStatusHandler) r.HandleFunc("/ui/index.html", ms.uiStatusHandler)
if !ms.option.DisableHttp {
r.HandleFunc("/dir/assign", ms.proxyToLeader(ms.guard.WhiteList(ms.dirAssignHandler))) r.HandleFunc("/dir/assign", ms.proxyToLeader(ms.guard.WhiteList(ms.dirAssignHandler)))
r.HandleFunc("/dir/lookup", ms.guard.WhiteList(ms.dirLookupHandler)) r.HandleFunc("/dir/lookup", ms.guard.WhiteList(ms.dirLookupHandler))
r.HandleFunc("/dir/status", ms.proxyToLeader(ms.guard.WhiteList(ms.dirStatusHandler))) r.HandleFunc("/dir/status", ms.proxyToLeader(ms.guard.WhiteList(ms.dirStatusHandler)))

20
weed/util/network.go

@ -7,16 +7,26 @@ import (
) )
func DetectedHostAddress() string { func DetectedHostAddress() string {
addrs, err := net.InterfaceAddrs()
netInterfaces, err := net.Interfaces()
if err != nil { if err != nil {
glog.V(0).Infof("failed to detect ip address: %v", err)
glog.V(0).Infof("failed to detect net interfaces: %v", err)
return "" return ""
} }
for _, netInterface := range netInterfaces {
if (netInterface.Flags & net.FlagUp) == 0 {
continue
}
addrs, err := netInterface.Addrs()
if err != nil {
glog.V(0).Infof("get interface addresses: %v", err)
}
for _, a := range addrs { for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
return ipnet.IP.String()
if ipNet, ok := a.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
if ipNet.IP.To4() != nil {
return ipNet.IP.String()
}
} }
} }
} }

Loading…
Cancel
Save