mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
go fmt
This commit is contained in:
parent
faaf44f171
commit
805740069a
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/go/glog"
|
||||
)
|
||||
|
@ -90,25 +90,24 @@ func (g *Guard) checkWhiteList(w http.ResponseWriter, r *http.Request) error {
|
|||
if err == nil {
|
||||
for _, ip := range g.whiteList {
|
||||
|
||||
// If the whitelist entry contains a "/" it
|
||||
// is a CIDR range, and we should check the
|
||||
// remote host is within it
|
||||
match, _ := regexp.MatchString("/", ip)
|
||||
if ( match ) {
|
||||
_, cidrnet, err := net.ParseCIDR(ip)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
remote := net.ParseIP(host)
|
||||
if cidrnet.Contains(remote) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// If the whitelist entry contains a "/" it
|
||||
// is a CIDR range, and we should check the
|
||||
// remote host is within it
|
||||
match, _ := regexp.MatchString("/", ip)
|
||||
if match {
|
||||
_, cidrnet, err := net.ParseCIDR(ip)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
remote := net.ParseIP(host)
|
||||
if cidrnet.Contains(remote) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Otherwise we're looking for a literal match.
|
||||
//
|
||||
//
|
||||
// Otherwise we're looking for a literal match.
|
||||
//
|
||||
if ip == host {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
func OnInterrupt(fn func()) {
|
||||
// deal with control+c,etc
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
// controlling terminal close, daemon not exit
|
||||
// controlling terminal close, daemon not exit
|
||||
signal.Ignore(syscall.SIGHUP)
|
||||
signal.Notify(signalChan,
|
||||
os.Interrupt,
|
||||
|
|
Loading…
Reference in a new issue