@@ -69,23 +69,24 @@ type responseStruct struct {
6969}
7070
7171type proxy struct {
72- scheme string
73- host string
74- region string
75- service string
76- endpoint string
77- verbose bool
78- prettify bool
79- logtofile bool
80- nosignreq bool
81- fileRequest * os.File
82- fileResponse * os.File
83- credentials * credentials.Credentials
84- httpClient * http.Client
85- auth bool
86- username string
87- password string
88- realm string
72+ scheme string
73+ host string
74+ region string
75+ service string
76+ endpoint string
77+ verbose bool
78+ prettify bool
79+ logtofile bool
80+ nosignreq bool
81+ fileRequest * os.File
82+ fileResponse * os.File
83+ credentials * credentials.Credentials
84+ httpClient * http.Client
85+ auth bool
86+ username string
87+ password string
88+ realm string
89+ remoteTerminate bool
8990}
9091
9192func newProxy (args ... interface {}) * proxy {
@@ -100,16 +101,17 @@ func newProxy(args ...interface{}) *proxy {
100101 }
101102
102103 return & proxy {
103- endpoint : args [0 ].(string ),
104- verbose : args [1 ].(bool ),
105- prettify : args [2 ].(bool ),
106- logtofile : args [3 ].(bool ),
107- nosignreq : args [4 ].(bool ),
108- httpClient : & client ,
109- auth : args [6 ].(bool ),
110- username : args [7 ].(string ),
111- password : args [8 ].(string ),
112- realm : args [9 ].(string ),
104+ endpoint : args [0 ].(string ),
105+ verbose : args [1 ].(bool ),
106+ prettify : args [2 ].(bool ),
107+ logtofile : args [3 ].(bool ),
108+ nosignreq : args [4 ].(bool ),
109+ httpClient : & client ,
110+ auth : args [6 ].(bool ),
111+ username : args [7 ].(string ),
112+ password : args [8 ].(string ),
113+ realm : args [9 ].(string ),
114+ remoteTerminate : args [10 ].(bool ),
113115 }
114116}
115117
@@ -210,7 +212,7 @@ func (p *proxy) getSigner() *v4.Signer {
210212}
211213
212214func (p * proxy ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
213- if r .URL .Path == "/terminate-proxy" && r .Method == http .MethodPost {
215+ if p . remoteTerminate && r .URL .Path == "/terminate-proxy" && r .Method == http .MethodPost {
214216 logrus .Infoln ("Terminate Signal" )
215217 os .Exit (0 )
216218 }
@@ -424,22 +426,23 @@ func copyHeaders(dst, src http.Header) {
424426func main () {
425427
426428 var (
427- debug bool
428- auth bool
429- username string
430- password string
431- realm string
432- verbose bool
433- prettify bool
434- logtofile bool
435- nosignreq bool
436- ver bool
437- endpoint string
438- listenAddress string
439- fileRequest * os.File
440- fileResponse * os.File
441- err error
442- timeout int
429+ debug bool
430+ auth bool
431+ username string
432+ password string
433+ realm string
434+ verbose bool
435+ prettify bool
436+ logtofile bool
437+ nosignreq bool
438+ ver bool
439+ endpoint string
440+ listenAddress string
441+ fileRequest * os.File
442+ fileResponse * os.File
443+ err error
444+ timeout int
445+ remoteTerminate bool
443446 )
444447
445448 flag .StringVar (& endpoint , "endpoint" , "" , "Amazon ElasticSearch Endpoint (e.g: https://dummy-host.eu-west-1.es.amazonaws.com)" )
@@ -455,6 +458,7 @@ func main() {
455458 flag .StringVar (& username , "username" , "" , "HTTP Basic Auth Username" )
456459 flag .StringVar (& password , "password" , "" , "HTTP Basic Auth Password" )
457460 flag .StringVar (& realm , "realm" , "" , "Authentication Required" )
461+ flag .BoolVar (& remoteTerminate , "remote-terminate" , false , "Allow HTTP remote termination" )
458462 flag .Parse ()
459463
460464 if endpoint == "" {
@@ -500,6 +504,7 @@ func main() {
500504 username ,
501505 password ,
502506 realm ,
507+ remoteTerminate ,
503508 )
504509
505510 if err = p .parseEndpoint (); err != nil {
0 commit comments