File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
SHELL = /bin/sh
2
2
3
- VERSION =0.9.5
3
+ VERSION =0.9.6
4
4
BUILD =` git rev-parse HEAD `
5
5
6
6
LDFLAGS =-ldflags "-w -s \
Original file line number Diff line number Diff line change 7
7
"log"
8
8
"net"
9
9
"net/http"
10
+ "os"
10
11
"strings"
11
12
"sync"
12
13
"time"
@@ -43,10 +44,28 @@ func Start() {
43
44
AllowCredentials : true ,
44
45
AllowedHeaders : []string {"authorization" },
45
46
AllowOriginFunc : func (origin string ) bool {
46
- dotTest := strings .HasSuffix (origin , ".test" )
47
- localhost := origin == "localhost"
47
+ allowedOrigins , ok := os .LookupEnv ("TESTTRACK_ALLOWED_ORIGINS" )
48
+ if ok {
49
+ for _ , allowedOrigin := range strings .Split (allowedOrigins , "," ) {
50
+ allowedOrigin = strings .Trim (allowedOrigin , " " )
51
+ if strings .HasSuffix (origin , allowedOrigin ) {
52
+ return true
53
+ }
54
+ }
55
+ } else {
56
+ // .test cannot be registered so we allow it by default
57
+ if strings .HasSuffix (origin , ".test" ) {
58
+ return true
59
+ }
60
+ }
61
+ if origin == "localhost" {
62
+ return true
63
+ }
48
64
ip := net .ParseIP (origin )
49
- return dotTest || localhost || (ip != nil && ip .IsLoopback ())
65
+ if ip != nil && ip .IsLoopback () {
66
+ return true
67
+ }
68
+ return false
50
69
},
51
70
}).Handler (r )))
52
71
}
You can’t perform that action at this time.
0 commit comments