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
c29fbdb6
Commit
c29fbdb6
authored
14 years ago
by
Zhenchao Li
Browse files
Options
Downloads
Patches
Plain Diff
enable FT over proxy
parent
2fec9f56
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/jingle_ft.py
+35
-2
35 additions, 2 deletions
src/common/jingle_ft.py
src/common/jingle_transport.py
+21
-0
21 additions, 0 deletions
src/common/jingle_transport.py
with
56 additions
and
2 deletions
src/common/jingle_ft.py
+
35
−
2
View file @
c29fbdb6
...
...
@@ -24,6 +24,7 @@ import xmpp
from
jingle_content
import
contents
,
JingleContent
from
jingle_transport
import
JingleTransportICEUDP
,
JingleTransportSocks5
from
common
import
helpers
from
common.socks5
import
Socks5Receiver
import
logging
...
...
@@ -99,6 +100,7 @@ class JingleFileTransfer(JingleContent):
file_props
[
'
transfered_size
'
]
=
[]
self
.
file_props
=
file_props
self
.
session
.
connection
.
files_props
[
file_props
[
'
sid
'
]]
=
file_props
if
self
.
transport
is
None
:
self
.
transport
=
JingleTransportSocks5
()
self
.
transport
.
set_our_jid
(
self
.
session
.
ourjid
)
...
...
@@ -134,13 +136,44 @@ class JingleFileTransfer(JingleContent):
def
__on_transport_info
(
self
,
stanza
,
content
,
error
,
action
):
log
.
info
(
"
__on_transport_info
"
)
jid
=
gajim
.
get_jid_without_resource
(
self
.
session
.
ourjid
)
gajim
.
socks5queue
.
send_file
(
self
.
file_props
,
jid
)
streamhost_cid
=
content
.
getTag
(
'
transport
'
).
getTag
(
'
candidate-used
'
).
getAttr
(
'
cid
'
)
streamhost_used
=
None
for
cand
in
self
.
transport
.
candidates
:
if
cand
[
'
candidate_id
'
]
==
streamhost_cid
:
streamhost_used
=
cand
break
if
streamhost_used
==
None
:
log
.
info
(
"
unknow streamhost
"
)
return
if
streamhost_used
[
'
type
'
]
==
'
proxy
'
:
self
.
file_props
[
'
streamhost-used
'
]
=
True
for
proxy
in
self
.
file_props
[
'
proxyhosts
'
]:
if
proxy
[
'
host
'
]
==
streamhost_used
[
'
host
'
]
and
\
proxy
[
'
port
'
]
==
streamhost_used
[
'
port
'
]
and
\
proxy
[
'
jid
'
]
==
streamhost_used
[
'
jid
'
]:
streamhost_used
=
proxy
break
if
'
streamhosts
'
not
in
self
.
file_props
:
self
.
file_props
[
'
streamhosts
'
]
=
[]
self
.
file_props
[
'
streamhosts
'
].
append
(
streamhost_used
)
self
.
file_props
[
'
is_a_proxy
'
]
=
True
receiver
=
Socks5Receiver
(
gajim
.
idlequeue
,
streamhost_used
,
self
.
file_props
[
'
sid
'
],
self
.
file_props
)
#gajim.socks5queue.add_file_props(self.session.ourjid, self.file_props)
gajim
.
socks5queue
.
add_receiver
(
self
.
session
.
ourjid
,
receiver
)
streamhost_used
[
'
idx
'
]
=
receiver
.
queue_idx
gajim
.
socks5queue
.
on_success
=
self
.
transport
.
_on_proxy_auth_ok
pass
else
:
jid
=
gajim
.
get_jid_without_resource
(
self
.
session
.
ourjid
)
gajim
.
socks5queue
.
send_file
(
self
.
file_props
,
jid
)
def
__on_iq_result
(
self
,
stanza
,
content
,
error
,
action
):
log
.
info
(
"
__on_iq_result
"
)
if
self
.
weinitiate
:
self
.
session
.
connection
.
files_props
[
self
.
file_props
[
'
sid
'
]]
=
self
.
file_props
receiver
=
self
.
file_props
[
'
receiver
'
]
sender
=
self
.
file_props
[
'
sender
'
]
...
...
This diff is collapsed.
Click to expand it.
src/common/jingle_transport.py
+
21
−
0
View file @
c29fbdb6
...
...
@@ -160,6 +160,8 @@ class JingleTransportSocks5(JingleTransport):
c
[
'
type
'
]
=
'
direct
'
c
[
'
jid
'
]
=
self
.
ourjid
c
[
'
priority
'
]
=
(
2
**
16
)
*
type_preference
c
[
'
initiator
'
]
=
self
.
file_props
[
'
sender
'
]
c
[
'
target
'
]
=
self
.
file_props
[
'
receiver
'
]
local_ip_cand
.
append
(
c
)
self
.
candidates
+=
local_ip_cand
...
...
@@ -181,6 +183,8 @@ class JingleTransportSocks5(JingleTransport):
c
[
'
type
'
]
=
'
direct
'
c
[
'
jid
'
]
=
self
.
ourjid
c
[
'
priority
'
]
=
(
2
**
16
)
*
type_preference
c
[
'
initiator
'
]
=
self
.
file_props
[
'
sender
'
]
c
[
'
target
'
]
=
self
.
file_props
[
'
receiver
'
]
additional_ip_cand
.
append
(
c
)
self
.
candidates
+=
additional_ip_cand
...
...
@@ -205,9 +209,26 @@ class JingleTransportSocks5(JingleTransport):
c
[
'
type
'
]
=
'
proxy
'
c
[
'
jid
'
]
=
proxyhost
[
'
jid
'
]
c
[
'
priority
'
]
=
(
2
**
16
)
*
type_preference
c
[
'
initiator
'
]
=
self
.
file_props
[
'
sender
'
]
c
[
'
target
'
]
=
self
.
file_props
[
'
receiver
'
]
proxy_cand
.
append
(
c
)
self
.
candidates
+=
proxy_cand
def
_on_proxy_auth_ok
(
self
,
proxy
):
log
.
info
(
'
proxy auth ok for
'
+
str
(
proxy
))
# send activate request to proxy, send activated confirmation to peer
if
not
self
.
connection
:
return
file_props
=
self
.
file_props
iq
=
xmpp
.
Iq
(
to
=
proxy
[
'
initiator
'
],
typ
=
'
set
'
)
auth_id
=
"
au_
"
+
proxy
[
'
sid
'
]
iq
.
setID
(
auth_id
)
query
=
iq
.
setTag
(
'
query
'
,
namespace
=
xmpp
.
NS_BYTESTREAM
)
query
.
setAttr
(
'
sid
'
,
proxy
[
'
sid
'
])
activate
=
query
.
setTag
(
'
activate
'
)
activate
.
setData
(
file_props
[
'
proxy_receiver
'
])
iq
.
setID
(
auth_id
)
self
.
connection
.
connection
.
send
(
iq
)
import
farsight
...
...
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