Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
shrapnel
Commits
fceed6bc
Commit
fceed6bc
authored
Aug 02, 2012
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quick test of ssl functionality
parent
0db99d1e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
coro/ssl/test/t_server.py
coro/ssl/test/t_server.py
+47
-0
No files found.
coro/ssl/test/t_server.py
0 → 100644
View file @
fceed6bc
# -*- Mode: Python -*-
import
coro
from
coro.ssl
import
openssl
import
coro.ssl
import
coro.backdoor
W
=
coro
.
write_stderr
ctx
=
openssl
.
ssl_ctx
()
ctx
.
use_cert
(
openssl
.
x509
(
open
(
'../../http/cert/server.crt'
).
read
()))
ctx
.
use_key
(
openssl
.
pkey
(
open
(
'../../http/cert/server.key'
).
read
(),
''
,
True
))
ctx
.
set_ciphers
(
'RC4-SHA:RC4-MD5:ALL'
)
#ctx.set_tmp_dh (openssl.dh_param (open ('../../http/cert/dh_param_1024.pem').read()))
#ctx.set_next_protos (['spdy/2', 'http/1.1'])
def
session
(
conn
,
addr
):
conn
.
ssl
.
set_fd
(
conn
.
fd
)
try
:
print
'conn='
,
conn
,
conn
.
__class__
while
1
:
block
=
conn
.
recv
(
1000
)
if
not
block
:
break
else
:
conn
.
send
(
block
)
finally
:
coro
.
sleep_relative
(
1000
)
W
(
'why for I exit?
\
n
'
)
all_conns
=
[]
def
serve
(
port
=
9000
):
s
=
coro
.
ssl
.
sock
(
ctx
)
s
.
bind
((
'0.0.0.0'
,
port
))
s
.
listen
(
50
)
print
's='
,
s
while
1
:
conn
,
addr
=
s
.
accept
()
print
'conn, addr='
,
conn
,
addr
all_conns
.
append
(
conn
)
coro
.
spawn
(
session
,
conn
,
addr
)
if
__name__
==
'__main__'
:
coro
.
spawn
(
coro
.
backdoor
.
serve
,
unix_path
=
'/tmp/xx.bd'
)
coro
.
spawn
(
serve
)
coro
.
event_loop
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment