Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
strudel2_backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
strudel2_backend
Commits
796746b8
Commit
796746b8
authored
5 years ago
by
Chris Hines
Browse files
Options
Downloads
Patches
Plain Diff
revert commits created trying to debug a safari issue .. it looks like the issue is on novnc
parent
34c7e73d
No related branches found
No related tags found
3 merge requests
!77
Revert "disable agressive kill and restart"
,
!35
Dev
,
!13
Dev
Pipeline
#7634
passed
5 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
TES/tes/apiendpoints.py
+1
-1
1 addition, 1 deletion
TES/tes/apiendpoints.py
TWS/twsproxy/__init__.py
+7
-28
7 additions, 28 deletions
TWS/twsproxy/__init__.py
with
8 additions
and
29 deletions
TES/tes/apiendpoints.py
+
1
−
1
View file @
796746b8
...
@@ -475,7 +475,7 @@ class CreateTunnel(Resource):
...
@@ -475,7 +475,7 @@ class CreateTunnel(Resource):
localbind
=
localbind
,
authtok
=
authtok
)
localbind
=
localbind
,
authtok
=
authtok
)
response
=
make_response
(
""
)
response
=
make_response
(
""
)
response
.
mime_type
=
'
application/json
'
response
.
mime_type
=
'
application/json
'
response
.
set_cookie
(
'
twsproxyauth
'
,
authtok
,
httponly
=
True
,
secure
=
True
,
samesite
=
'
Strict
'
)
response
.
set_cookie
(
'
twsproxyauth
'
,
authtok
)
logger
.
debug
(
'
JobConnect.connect: connecting via redirect with cookie authtok set to {}
'
.
format
(
authtok
))
logger
.
debug
(
'
JobConnect.connect: connecting via redirect with cookie authtok set to {}
'
.
format
(
authtok
))
return
response
return
response
...
...
This diff is collapsed.
Click to expand it.
TWS/twsproxy/__init__.py
+
7
−
28
View file @
796746b8
...
@@ -41,7 +41,7 @@ class TWSProxy(threading.Thread):
...
@@ -41,7 +41,7 @@ class TWSProxy(threading.Thread):
header
[
bytessofar
:
bytessofar
+
len
(
partial
)]
=
partial
header
[
bytessofar
:
bytessofar
+
len
(
partial
)]
=
partial
bytessofar
=
bytessofar
+
len
(
partial
)
bytessofar
=
bytessofar
+
len
(
partial
)
logger
.
debug
(
'
inittws, checking headers
'
)
logger
.
debug
(
'
inittws, checking headers
'
)
port
=
self
.
verifyauth
(
header
[
0
:
bytessofar
])
port
=
TWSProxy
.
verifyauth
(
header
[
0
:
bytessofar
])
if
port
is
not
None
:
if
port
is
not
None
:
logger
.
debug
(
'
inittws, found auth token and got port {}
'
.
format
(
port
))
logger
.
debug
(
'
inittws, found auth token and got port {}
'
.
format
(
port
))
keepreading
=
False
keepreading
=
False
...
@@ -49,9 +49,7 @@ class TWSProxy(threading.Thread):
...
@@ -49,9 +49,7 @@ class TWSProxy(threading.Thread):
logger
.
debug
(
'
inittws, no authtok found in the first {} bytes
'
.
format
(
bytessofar
))
logger
.
debug
(
'
inittws, no authtok found in the first {} bytes
'
.
format
(
bytessofar
))
else
:
else
:
logger
.
debug
(
'
inittws, select returned with no more info, verifying headers for the last time
'
)
logger
.
debug
(
'
inittws, select returned with no more info, verifying headers for the last time
'
)
port
=
self
.
verifyauth
(
header
[
0
:
bytessofar
])
port
=
TWSProxy
.
verifyauth
(
header
[
0
:
bytessofar
])
logger
.
debug
(
header
[
0
:
bytessofar
])
keepreading
=
False
keepreading
=
False
if
initcount
>
failthresh
:
if
initcount
>
failthresh
:
logger
.
debug
(
'
inittws, checked headers enough times, got {} bytes with no success
'
.
format
(
bytessofar
))
logger
.
debug
(
'
inittws, checked headers enough times, got {} bytes with no success
'
.
format
(
bytessofar
))
...
@@ -79,12 +77,6 @@ class TWSProxy(threading.Thread):
...
@@ -79,12 +77,6 @@ class TWSProxy(threading.Thread):
return
(
None
,
None
)
return
(
None
,
None
)
def
insert_header
(
self
,
buff
,
insertafter
,
extraheader
):
try
:
index
=
buff
.
decode
().
index
(
insertafter
.
decode
())
except
:
return
buff
return
buff
[
0
:
index
]
+
extraheader
+
buff
[
index
:]
def
run
(
self
):
def
run
(
self
):
import
logging
import
logging
...
@@ -93,11 +85,6 @@ class TWSProxy(threading.Thread):
...
@@ -93,11 +85,6 @@ class TWSProxy(threading.Thread):
initshutdown
=
threading
.
Event
()
initshutdown
=
threading
.
Event
()
initshutdown
.
clear
()
initshutdown
.
clear
()
(
header
,
bytessofar
)
=
self
.
inittws
(
initshutdown
)
(
header
,
bytessofar
)
=
self
.
inittws
(
initshutdown
)
if
self
.
authtok
is
not
None
:
replyheader
=
b
'
Set-Cookie: twsproxyauth2=
'
+
self
.
authtok
+
b
'
; HttpOnly; SameSite=Lax; Path=/
\r\n
'
else
:
replyheader
=
None
insertafter
=
b
'
HTTP/1.1 200 OK
\r\n
'
logger
.
debug
(
'
connecting {} to {}
'
.
format
(
self
.
csock
,
self
.
ssock
))
logger
.
debug
(
'
connecting {} to {}
'
.
format
(
self
.
csock
,
self
.
ssock
))
if
initshutdown
.
isSet
():
if
initshutdown
.
isSet
():
logger
.
debug
(
'
NOT connecting {} inittws did not connect us
'
.
format
(
self
.
csock
))
logger
.
debug
(
'
NOT connecting {} inittws did not connect us
'
.
format
(
self
.
csock
))
...
@@ -110,7 +97,7 @@ class TWSProxy(threading.Thread):
...
@@ -110,7 +97,7 @@ class TWSProxy(threading.Thread):
TWSProxy
.
reliablesend
(
self
.
ssock
,
header
[
0
:
bytessofar
],
bytessofar
)
TWSProxy
.
reliablesend
(
self
.
ssock
,
header
[
0
:
bytessofar
],
bytessofar
)
logger
.
debug
(
'
creating threads
'
)
logger
.
debug
(
'
creating threads
'
)
# TWSProxy.twosocks(self.csock,self.ssock,initshutdown)
# TWSProxy.twosocks(self.csock,self.ssock,initshutdown)
t1
=
threading
.
Thread
(
target
=
TWSProxy
.
sockcopy
,
args
=
(
self
.
ssock
,
self
.
csock
,
initshutdown
,
insertafter
,
replyheader
),
name
=
'
s2c
'
)
t1
=
threading
.
Thread
(
target
=
TWSProxy
.
sockcopy
,
args
=
(
self
.
ssock
,
self
.
csock
,
initshutdown
),
name
=
'
s2c
'
)
t2
=
threading
.
Thread
(
target
=
TWSProxy
.
sockcopy
,
args
=
(
self
.
csock
,
self
.
ssock
,
initshutdown
),
name
=
'
c2s
'
)
t2
=
threading
.
Thread
(
target
=
TWSProxy
.
sockcopy
,
args
=
(
self
.
csock
,
self
.
ssock
,
initshutdown
),
name
=
'
c2s
'
)
t1
.
start
()
t1
.
start
()
t2
.
start
()
t2
.
start
()
...
@@ -124,11 +111,12 @@ class TWSProxy(threading.Thread):
...
@@ -124,11 +111,12 @@ class TWSProxy(threading.Thread):
if
self
.
csock
is
not
None
:
if
self
.
csock
is
not
None
:
self
.
csock
.
close
()
self
.
csock
.
close
()
def
verifyauth
(
self
,
header
):
@staticmethod
def
verifyauth
(
header
):
import
re
import
re
import
requests
import
requests
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
token
=
b
'
twsproxyauth
[0-9]*
=(?P<authtok>\w+)[\W|$]
'
token
=
b
'
twsproxyauth=(?P<authtok>\w+)[\W|$]
'
m
=
re
.
search
(
token
,
header
)
m
=
re
.
search
(
token
,
header
)
if
m
:
if
m
:
authtok
=
m
.
groupdict
()[
'
authtok
'
]
authtok
=
m
.
groupdict
()[
'
authtok
'
]
...
@@ -146,7 +134,6 @@ class TWSProxy(threading.Thread):
...
@@ -146,7 +134,6 @@ class TWSProxy(threading.Thread):
except
:
except
:
logger
.
error
(
'
authtok found port found {}
'
.
format
(
port
))
logger
.
error
(
'
authtok found port found {}
'
.
format
(
port
))
raise
Exception
(
'
unable to get a port number for the authtok {}
'
.
format
(
r
.
text
))
raise
Exception
(
'
unable to get a port number for the authtok {}
'
.
format
(
r
.
text
))
self
.
authtok
=
authtok
return
port
return
port
return
None
return
None
# if m:
# if m:
...
@@ -216,7 +203,7 @@ class TWSProxy(threading.Thread):
...
@@ -216,7 +203,7 @@ class TWSProxy(threading.Thread):
@staticmethod
@staticmethod
def
sockcopy
(
src
,
dest
,
initshutdown
,
insertafter
=
None
,
insert
=
None
):
def
sockcopy
(
src
,
dest
,
initshutdown
):
shuttype
=
socket
.
SHUT_RD
shuttype
=
socket
.
SHUT_RD
import
threading
import
threading
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
...
@@ -233,14 +220,6 @@ class TWSProxy(threading.Thread):
...
@@ -233,14 +220,6 @@ class TWSProxy(threading.Thread):
msglength
=
-
1
msglength
=
-
1
try
:
try
:
buff
=
src
.
recv
(
TWSProxy
.
MAXBUFF
)
buff
=
src
.
recv
(
TWSProxy
.
MAXBUFF
)
if
insert
is
not
None
:
try
:
index
=
buff
.
decode
().
index
(
insertafter
.
decode
())
newbuff
=
buff
[
0
:
index
+
len
(
insertafter
)]
+
insert
+
buff
[
index
+
len
(
insertafter
):]
buff
=
newbuff
insert
=
None
except
:
pass
if
buff
is
None
:
if
buff
is
None
:
continue
continue
except
ConnectionResetError
as
e
:
except
ConnectionResetError
as
e
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment