将旁遮普语设置为 Facebook 聊天的 BOSH XMPP 代理

Posted

技术标签:

【中文标题】将旁遮普语设置为 Facebook 聊天的 BOSH XMPP 代理【英文标题】:Set Punjab as a BOSH XMPP Proxy for Facebook Chat 【发布时间】:2012-03-09 09:02:58 【问题描述】:

我想使用 Punjab 作为 Facebook Chat 的 xmpp 代理

Punjab 运行良好,但是当我询问 chat.facebook.com 时它不起作用

SENT: <body rid='313820892' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='300' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xml='http://www.w3.org/XML/1998/namespace' xmlns:xmpp='urn:xmpp:xbosh'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind' type='terminate' condition='remote-connection-failed'/>

当我们查看旁遮普语日志时,我们会看到旁遮普语连接到 chat.facebook.com 但没有任何答案

2012/03/09 10:42 +0200 [-] Log opened.
2012/03/09 10:42 +0200 [-] twistd 2.5.0 (/usr/bin/python 2.5.0) starting up
2012/03/09 10:42 +0200 [-] reactor class: <class 'twisted.internet.selectreactor.SelectReactor'>
2012/03/09 10:42 +0200 [-] Loading punjab.tac...
2012/03/09 10:42 +0200 [-] twisted.web.server.Site starting on 5281
2012/03/09 10:42 +0200 [-] Starting factory <twisted.web.server.Site instance at 0xb785c58c>
2012/03/09 10:42 +0200 [-] Loaded.
2012/03/09 10:42 +0200 [-] twisted.web.server.Site starting on 5280
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] HEADERS 1331282556.16:
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] 'origin': 'http://mydomain.tld', 'content-length': '264', 'via': '1.1 mydomain.tld', 'accept-language': 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip,deflate,sdch', 'x-forwarded-host': 'mydomain.tld', 'x-forwarded-for': 'XXX.XXX.XXX.XXX', 'connection': 'Keep-Alive', 'accept': '*/*', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (Khtml, like Gecko) Ubuntu/11.10 Chromium/17.0.963.65 Chrome/17.0.963.65 Safari/535.11', 'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'host': 'localhost:5280', 'referer': 'http://mydomain.tld/facebook/', 'max-forwards': '10', 'cookie': '_jsuid=2679835210; fbm_XXXXXXXXX=base_domain=.mydomain.tld; fbsr_XXXXXXXXX=XXXXXXXXX', 'x-forwarded-server': 'mydomain.tld', 'content-type': 'application/xml'
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] HTTPB POST : 
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] <body rid='XXXXXXXXX' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='300' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xml='http://www.w3.org/XML/1998/namespace' xmlns:xmpp='urn:xmpp:xbosh'/>
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] Session Created : afeb0b2bf66d6ca8b5f5fee83ebbb449b64f4c65 1331282556.16
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] ================================== 1331282556.17 connect to chat.facebook.com:5222 ==================================
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] twisted.names.dns.DNSDatagramProtocol starting on 55647
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> will retry in 3 seconds
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [-] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> will retry in 10 seconds
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [-] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Abandoning <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> after 3 retries.
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:43 +0200 [-] ================================== afeb0b2bf66d6ca8b5f5fee83ebbb449b64f4c65 1331282584.43 startup timeout ==================================
2012/03/09 10:43 +0200 [-] HTTPB Error 200
2012/03/09 10:43 +0200 [-] HTTPB Return Error: 200 -> <body xmlns='http://jabber.org/protocol/httpbind' type='terminate' condition='remote-connection-failed'/>

我的 punjab tac 文件,其中包含 facebook 的 ssl 配置:

# punjab tac file
from twisted.web import server, resource, static
from twisted.application import service, internet
from twisted.internet import reactor, ssl

from punjab.httpb  import Httpb, HttpbService

root = static.File("./html")

bosh = HttpbService(1)

root.putChild('http-bind', resource.IResource(bosh))

site  = server.Site(root)

application = service.Application("punjab")
internet.TCPServer(5280, site).setServiceParent(application)

#
# RMW adding TLS support for Facebook chat/xmpp support
#
sslContext = ssl.DefaultOpenSSLContextFactory(
        '/root/punjab_privkey.pem',
        '/root/punjab_cacert.pem',
)
reactor.listenSSL(
        5281,
        site,
        contextFactory=sslContext,
)

你知道为什么我没有从 chat.facebook.com 得到任何答复吗?

谢谢

【问题讨论】:

【参考方案1】:

我找到了答案 我在 punjab.tac 中添加这一行以获得正确的 DNS 查找

bosh.connect_srv = False

就在这一行之后

bosh = HttpbService(1)

【讨论】:

旁遮普语可以与 facebook 聊天一起使用吗?你能分享一下吗?我想在网站上集成 facebook 聊天。【参考方案2】:

您可以完全禁用证书验证(警告:不安全)

把它放在punjab.tac 文件中

from twisted.internet import _sslverify
_sslverify.platformTrust = lambda : None

【讨论】:

以上是关于将旁遮普语设置为 Facebook 聊天的 BOSH XMPP 代理的主要内容,如果未能解决你的问题,请参考以下文章

与 Facebook 聊天连接时远程连接失败

将旁遮普语文本转换为英文文本

无法安装旁遮普语

如何扩展旁遮普语 bosh 连接管理器?

无法运行旁遮普语

如何让旁遮普语/扭曲绕过 dns