This repository was archived by the owner on Oct 2, 2020. It is now read-only.
File tree 3 files changed +6
-2
lines changed
3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ something like this:
54
54
55
55
location /hook {
56
56
proxy_pass http://localhost:8000;
57
+ proxy_set_header X-Real-IP $remote_addr;
57
58
}
Original file line number Diff line number Diff line change @@ -63,13 +63,16 @@ def hook_publish():
63
63
hook = matches [0 ]
64
64
65
65
allow = False
66
+ remote = request .remote_addr
67
+ if remote == "127.0.0.1" and "X-Real-IP" in request .headers :
68
+ remote = request .headers .get ("X-Real-IP" )
66
69
for ip in hook .valid_ips .split ("," ):
67
70
parts = ip .split ("/" )
68
71
range = 32
69
72
if len (parts ) != 1 :
70
73
range = int (parts [1 ])
71
74
addr = networkMask (parts [0 ], range )
72
- if addressInNetwork (dottedQuadToNum (request . remote_addr ), addr ):
75
+ if addressInNetwork (dottedQuadToNum (remote ), addr ):
73
76
allow = True
74
77
if not allow :
75
78
return "Hook rejected: unauthorized IP" , 403
Original file line number Diff line number Diff line change 5
5
url = "https://github.com/SirCmpwn/hooks" ,
6
6
description = "Executes commands based on Github hooks" ,
7
7
license = "MIT" ,
8
- version = "1.0 " ,
8
+ version = "1.1 " ,
9
9
scripts = ["ghhooks" ],
10
10
py_modules = ["hooks" ],
11
11
install_requires = ["Flask" ])
You can’t perform that action at this time.
0 commit comments