cleanup, escape resource

This commit is contained in:
veclav talica 2023-08-26 20:23:27 +05:00
parent aa7a5e89ec
commit 42876ae30c

View File

@ -6,15 +6,13 @@ class Connection extends Reference:
var domain: String
var bare_jid: String
var jid: String
var id_counter: int = 0
var _id_counter: int = 0
func generate_id() -> int:
self.id_counter += 1
return hash(self.id_counter)
self._id_counter += 1
return hash(self._id_counter)
func establish_new_connection(domain: String, identity: String, password: String) -> Connection:
## XMPP uses unidirectional pipes for communication, which means
## multiple connections are open over different predefined ports.
var stream := StreamPeerTCP.new()
if stream.connect_to_host(domain, 5222) != OK:
push_error("Cannot establish client->server pipe to " + domain)
@ -245,7 +243,7 @@ func _bind_resource(connection: Connection, resource: String = "tochie-facade")
<resource>{resource}</resource>
</bind></iq>""".format({
"id": iq_id,
"resource": resource
"resource": resource.xml_escape()
}).to_utf8()) != OK:
return ERR_CONNECTION_ERROR