Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
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
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
Weblate
gajim
Commits
c204880c
Commit
c204880c
authored
19 years ago
by
dkirov
Browse files
Options
Downloads
Patches
Plain Diff
moved socks5queu to gajim.py in order to have
only one queue
parent
8031bed4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/xmpp/client.py
+7
-0
7 additions, 0 deletions
src/common/xmpp/client.py
src/common/xmpp/socks5.py
+44
-8
44 additions, 8 deletions
src/common/xmpp/socks5.py
with
51 additions
and
8 deletions
src/common/xmpp/client.py
+
7
−
0
View file @
c204880c
...
...
@@ -148,6 +148,13 @@ class CommonClient:
self
.
Dispatcher
.
restoreHandlers
(
handlerssave
)
return
self
.
connected
def
get_peerhost
(
self
):
'''
get the ip address of the account, from which is made connection
to the server , (e.g. me).
We will create listening socket on the same ip
'''
if
self
.
Connection
:
return
self
.
Connection
.
_sock
.
getsockname
()
def
connect
(
self
,
server
=
None
,
proxy
=
None
,
ssl
=
None
):
"""
Make a tcp/ip connection, protect it with tls/ssl if possible and start XMPP stream.
"""
if
not
server
:
server
=
(
self
.
Server
,
self
.
Port
)
...
...
This diff is collapsed.
Click to expand it.
src/common/xmpp/socks5.py
+
44
−
8
View file @
c204880c
...
...
@@ -38,12 +38,16 @@ class SocksQueue:
self
.
idx
=
0
self
.
complete_transfer_cb
=
complete_transfer_cb
self
.
progress_transfer_cb
=
progress_transfer_cb
def
start_listener
(
self
):
Socks5Sender
()
def
add_receiver
(
self
,
sock5_receiver
):
def
add_receiver
(
self
,
account
,
sock5_receiver
):
'''
add new file request
'''
self
.
readers
[
self
.
idx
]
=
sock5_receiver
sock5_receiver
.
queue_idx
=
self
.
idx
sock5_receiver
.
queue
=
self
sock5_receiver
.
account
=
account
self
.
idx
+=
1
result
=
sock5_receiver
.
connect
()
self
.
connected
+=
1
...
...
@@ -52,16 +56,20 @@ class SocksQueue:
sock5_receiver
.
_sock
.
setblocking
(
False
)
return
result
def
add_file_props
(
self
,
file_props
):
def
add_file_props
(
self
,
account
,
file_props
):
if
file_props
is
None
or
\
file_props
.
has_key
(
'
sid
'
)
is
False
:
return
id
=
file_props
[
'
sid
'
]
self
.
files_props
[
id
]
=
file_props
if
not
self
.
files_props
.
has_key
(
account
):
self
.
files_props
[
account
]
=
{}
self
.
files_props
[
account
][
id
]
=
file_props
def
get_file_props
(
self
,
id
):
if
self
.
files_props
.
has_key
(
id
):
return
self
.
files_props
[
id
]
def
get_file_props
(
self
,
account
,
id
):
if
self
.
files_props
.
has_key
(
account
):
fl_props
=
self
.
files_props
[
account
]
if
fl_props
.
has_key
(
id
):
return
fl_props
[
id
]
return
None
def
process
(
self
,
timeout
=
0
):
...
...
@@ -75,10 +83,12 @@ class SocksQueue:
result
=
receiver
.
get_file_contents
(
timeout
)
if
result
in
[
0
,
-
1
]
and
\
self
.
complete_transfer_cb
is
not
None
:
self
.
complete_transfer_cb
(
receiver
.
file_props
)
self
.
complete_transfer_cb
(
receiver
.
account
,
receiver
.
file_props
)
elif
self
.
progress_transfer_cb
is
not
None
:
self
.
progress_transfer_cb
(
receiver
.
file_props
)
self
.
progress_transfer_cb
(
receiver
.
account
,
receiver
.
file_props
)
else
:
self
.
remove_receiver
(
idx
)
...
...
@@ -97,6 +107,7 @@ class Socks5:
self
.
target
=
target
self
.
sid
=
sid
self
.
_sock
=
None
self
.
account
=
None
def
connect
(
self
):
self
.
_sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
...
...
@@ -152,6 +163,15 @@ class Socks5:
return
select
.
select
([
self
.
_sock
],[],[],
timeout
)[
0
]
except
:
return
False
def
pending_connection
(
self
,
timeout
=
0
):
'''
Returns true if there is a data ready to be read.
'''
if
self
.
_sock
is
None
:
return
False
try
:
return
select
.
select
([],[
self
.
_sock
],[],
timeout
)[
0
]
except
:
return
False
def
send_connect
(
self
):
'''
begin negotiation. on success
'
address
'
!= 0
'''
...
...
@@ -207,6 +227,21 @@ class Socks5:
def
_get_sha1_auth
(
self
):
return
sha
.
new
(
"
%s%s%s
"
%
(
self
.
sid
,
self
.
initiator
,
self
.
target
)).
hexdigest
()
class
Socks5Listener
:
def
__init__
(
self
,
host
,
port
):
self
.
host
,
self
.
port
self
.
queue_idx
=
-
1
self
.
queue
=
None
def
bind
(
self
):
self
.
_serv
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
_serv
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
self
.
_serv
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_KEEPALIVE
,
1
)
self
.
_serv
.
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
1
)
self
.
_serv
.
bind
((
self
.
host
,
self
.
port
))
self
.
_serv
.
listen
(
socket
.
SOMAXCONN
)
self
.
connected
=
False
class
Socks5Receiver
(
Socks5
):
def
__init__
(
self
,
host
,
port
,
initiator
,
target
,
sid
,
file_props
=
None
):
...
...
@@ -273,3 +308,4 @@ class Socks5Receiver(Socks5):
self
.
file_props
[
'
disconnect_cb
'
]
=
None
if
self
.
queue
is
not
None
:
self
.
queue
.
remove_receiver
(
self
.
queue_idx
)
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