@@ -22,7 +22,6 @@ import (
22
22
"net"
23
23
"net/url"
24
24
"os"
25
- "strings"
26
25
"time"
27
26
28
27
"github.com/minio/minio-go/v7"
@@ -117,16 +116,24 @@ func main() {
117
116
os .Exit (1 )
118
117
}
119
118
120
- func exactIP (urll string ) string {
121
- u , _ := url .Parse (urll )
122
- host , _ , err := net .SplitHostPort (u .Host )
123
- if err != nil {
124
- host = u .Host
125
- }
126
- if strings .HasSuffix (host , ":" ) {
127
- host = host [0 : len (host )- 1 ]
119
+ func checkMinioIP () error {
120
+ for _ , i := range []string {config .Config .Object .ApiURL , config .Config .Object .Minio .SignEndpoint } {
121
+ u , err := url .Parse (i )
122
+ if err != nil {
123
+ return utils .Wrap (err , "api format error,please check config file apiURL or Minio SignEndpoint" )
124
+ }
125
+ if u .Scheme == "https" {
126
+ continue
127
+ }
128
+ host , _ , err := net .SplitHostPort (u .Host )
129
+ if err != nil {
130
+ host = u .Host
131
+ }
132
+ if host == "127.0.0.1" {
133
+ return ErrConfig .Wrap ("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1,please modify it" )
134
+ }
128
135
}
129
- return host
136
+ return nil
130
137
}
131
138
132
139
func checkMysql () error {
@@ -205,8 +212,8 @@ func checkMinio() error {
205
212
return ErrComponentStart .Wrap ("Minio server is offline" )
206
213
}
207
214
}
208
- if exactIP ( config . Config . Object . ApiURL ) == "127.0.0.1" || exactIP ( config . Config . Object . Minio . SignEndpoint ) == "127.0.0.1" {
209
- return ErrConfig . Wrap ( "apiURL or Minio SignEndpoint endpoint contain 127.0.0.1" )
215
+ if checkMinioIP () != nil {
216
+ return checkMinioIP ( )
210
217
}
211
218
}
212
219
return nil
0 commit comments