mirror of
https://port.numenaute.org/aleajactaest/bazar_alea.git
synced 2024-11-26 00:56:21 +00:00
adding xmpp
This commit is contained in:
parent
7d3f028768
commit
7c40a3d053
11 changed files with 718 additions and 19 deletions
|
@ -18,6 +18,7 @@ extends Node
|
|||
|
||||
signal send_msg_debug(message:String)
|
||||
signal send_msg_error(message:String)
|
||||
signal chat_connected()
|
||||
signal new_stanza(stanza)
|
||||
|
||||
enum StreamState {
|
||||
|
@ -52,6 +53,7 @@ enum XMPPState {
|
|||
AUTHENTICATED, # We finished authenticate
|
||||
NOT_AUTHORIZED, # Not Authorize
|
||||
ACCOUNT_DISABLED, # Account Disable
|
||||
SENDED_START_STREAM,
|
||||
}
|
||||
|
||||
enum ResultAuthenticate {
|
||||
|
@ -143,13 +145,14 @@ var status:StreamState = StreamState.END
|
|||
var xmpp_state = XMPPState.NONE
|
||||
var authentication_methods = []
|
||||
var selected_mechanism_authenticate:String = ""
|
||||
#var order_preference_mechanism_authenticate: Array = ['PLAIN']
|
||||
var order_preference_mechanism_authenticate: Array = ['DIGEST-MD5']
|
||||
var banned_mechanism_authenticate:Array = []
|
||||
var order_preference_mechanism_authenticate: Array = ['PLAIN']
|
||||
#var order_preference_mechanism_authenticate: Array = ['DIGEST-MD5']
|
||||
var banned_mechanism_authenticate:Array = ['DIGEST-MD5']
|
||||
#DIGEST-MD5, PLAIN, SCRAM-SHA-512-PLUS, SCRAM-SHA-512, SCRAM-SHA-256-PLUS, SCRAM-SHA-256, SCRAM-SHA-1-PLUS, SCRAM-SHA-1, X-OAUTH2
|
||||
var auhtentification_step:int = 0
|
||||
var auhtentification_challenge:Array = []
|
||||
|
||||
const listcar:String = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789"
|
||||
|
||||
#func reinit_stream():
|
||||
# if ssl_peer != null:
|
||||
|
@ -172,6 +175,21 @@ func _init() -> void:
|
|||
# reinit_stream()
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
var n1:PackedByteArray = set_PackedByteArray("Mufasa:testrealm@host.com:Circle Of Life")
|
||||
var n2:PackedByteArray = hash_md5(n1)
|
||||
print("n2:", n2.hex_encode())
|
||||
var exemple = digest_md5( "Mufasa", "Circle Of Life", "testrealm@host.com", "dcd98b7102dd2f0e8b11d0f600bfb0c093", "/dir/index.html", "auth", "00000001", "0a4f113b", "utf-8", "md5-sess" )
|
||||
print("exemple:", exemple)
|
||||
|
||||
|
||||
exemple = digest_md5( "rob", "Circle Of Life", "cataclysm.cx", "OA6MG9tEQGm2hh", "xmpp/
|
||||
cataclysm.cx", "auth", "00000001", "OA6MHXh6VqTrRk", "utf-8", "md5-sess" )
|
||||
print("exemple 2:", exemple)
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
#print(server_xmpp_name, ":", port_number, " / get_status:" , tcp_peer.get_status(), " / count_connecting_time:", count_connecting_time, " / stream_status:", stream_status, " / xmpp_state:", XMPPState.keys()[xmpp_state])
|
||||
if xmppclient == false:
|
||||
|
@ -426,6 +444,45 @@ func _process(delta) -> void:
|
|||
count_connecting_time = 0
|
||||
xmpp_state = XMPPState.SELECT_MECHANISM_AUTHENTICATE
|
||||
banned_mechanism_authenticate.append(selected_mechanism_authenticate)
|
||||
if xmpp_state == XMPPState.AUTHENTICATED:
|
||||
if tcp_peer.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
xmpp_state = XMPPState.NONE
|
||||
count_connecting_time = 0
|
||||
#send_msg_debug.emit("Stream: Lost flow 1")
|
||||
#send_msg_debug.emit("Stream: Lost flow 1 : " + str(tcp_peer.get_status()) )
|
||||
return
|
||||
if (ssl_peer.has_method("poll")):
|
||||
ssl_peer.poll()
|
||||
if tcp_peer.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
xmpp_state = XMPPState.NONE
|
||||
count_connecting_time = 0
|
||||
#send_msg_debug.emit("Stream: Lost flow 2 : " + str(tcp_peer.get_status()) )
|
||||
return
|
||||
if ssl_peer.get_available_bytes()>0:
|
||||
var response = ssl_peer.get_string(ssl_peer.get_available_bytes())
|
||||
send_msg_debug.emit("Stream: response: " + response)
|
||||
start_stream()
|
||||
if xmpp_state == XMPPState.SENDED_START_STREAM:
|
||||
if tcp_peer.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
xmpp_state = XMPPState.NONE
|
||||
count_connecting_time = 0
|
||||
#send_msg_debug.emit("Stream: Lost flow 1")
|
||||
#send_msg_debug.emit("Stream: Lost flow 1 : " + str(tcp_peer.get_status()) )
|
||||
return
|
||||
if (ssl_peer.has_method("poll")):
|
||||
ssl_peer.poll()
|
||||
if tcp_peer.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
xmpp_state = XMPPState.NONE
|
||||
count_connecting_time = 0
|
||||
#send_msg_debug.emit("Stream: Lost flow 2 : " + str(tcp_peer.get_status()) )
|
||||
return
|
||||
if ssl_peer.get_available_bytes()>0:
|
||||
var response = ssl_peer.get_string(ssl_peer.get_available_bytes())
|
||||
send_msg_debug.emit("Stream: response: " + response)
|
||||
response = remove_stream_header(response)
|
||||
if not analyze_error(response):
|
||||
analyze_stream(response)
|
||||
# chat_connected.emit()
|
||||
|
||||
|
||||
func get_xml_data(response:String, nodes:Array) -> String:
|
||||
|
@ -517,8 +574,8 @@ func analyze_error(response:String) -> bool:
|
|||
var stream_error = XMPPStreamError.new()
|
||||
stream_error.parse_from_xml(response)
|
||||
var error_name = stream_error.error_name_for_enum(stream_error.error_type)
|
||||
var error = tr('A stream error of type "%" occured, or in other words: % (Stream errors cannot be recovered from, the connection will be closed.'.format([error_name, stream_error.human_friendly_error_message()], "%)"))
|
||||
error.emit(error)
|
||||
var error:String = tr('A stream error of type "%" occured, or in other words: % (Stream errors cannot be recovered from, the connection will be closed.'.format([error_name, stream_error.human_friendly_error_message()], "%)"))
|
||||
send_msg_error.emit(error)
|
||||
return true
|
||||
return false
|
||||
|
||||
|
@ -614,7 +671,7 @@ func negotiate_ssl_authenticate_plain() -> void:
|
|||
# UTF8NUL
|
||||
msg.push_back(0)
|
||||
# authcid
|
||||
var t = account_name.split("@")[0]
|
||||
var t:String = account_name.split("@")[0]
|
||||
msg += t.to_ascii_buffer()
|
||||
# UTF8NUL
|
||||
msg.push_back(0)
|
||||
|
@ -628,7 +685,96 @@ func negotiate_ssl_authenticate_plain() -> void:
|
|||
send_ssl_string(request_sasl)
|
||||
|
||||
|
||||
func hash_md5(data:PackedByteArray ) -> PackedByteArray:
|
||||
var ctx = HashingContext.new()
|
||||
ctx.start(HashingContext.HASH_MD5)
|
||||
ctx.update(data)
|
||||
var res = ctx.finish()
|
||||
# Print the result as hex string and array.
|
||||
printt("hash_md5:", res.hex_encode(), Array(res))
|
||||
return res
|
||||
|
||||
|
||||
func set_PackedByteArray(data:String) -> PackedByteArray:
|
||||
# var ret:PackedByteArray = PackedByteArray()
|
||||
# for item in data:
|
||||
# print(item)
|
||||
return data.to_ascii_buffer()
|
||||
|
||||
|
||||
func digest_md5(username:String, password:String, realm:String, nonce:String, uri:String, qop:String, nc:String, cnonce:String, charset:String, algorithm:String) -> String:
|
||||
if qop != "auth" and qop != "auth-int":
|
||||
send_msg_error.emit("Stream: Authenticate digest-md5, qop unknonw (%s)" % qop)
|
||||
return ""
|
||||
if charset != "utf-8":
|
||||
send_msg_error.emit("Stream: Authenticate digest-md5, charset unknonw (%s)" % charset)
|
||||
return ""
|
||||
if algorithm != "md5-sess":
|
||||
send_msg_error.emit("Stream: Authenticate digest-md5, algorithm unknonw (%s)" % algorithm)
|
||||
return ""
|
||||
#var serv_type:String = "xmpp"
|
||||
|
||||
var X:String = username + ":" + realm + ":" + password
|
||||
print("X:", X)
|
||||
var Y:String = hash_md5(set_PackedByteArray(X)).hex_encode()
|
||||
print("Y:", Y)
|
||||
var A1:String = Y + ":" + nonce + ":" + cnonce
|
||||
print("A1:", A1)
|
||||
var A2:String = "AUTHENTICATE:" + uri
|
||||
print("A2:", A2)
|
||||
var HA1:String = hash_md5(set_PackedByteArray(A1)).hex_encode()
|
||||
print("HA1:", HA1)
|
||||
var HA2:String = hash_md5(set_PackedByteArray(A2)).hex_encode()
|
||||
print("HA2:", HA2)
|
||||
var KD:String = HA1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + HA2
|
||||
print("KD:", KD)
|
||||
var Z:String = hash_md5(set_PackedByteArray(KD)).hex_encode()
|
||||
print("Z:", Z)
|
||||
#
|
||||
# var HA1a:PackedByteArray = set_PackedByteArray(username + ":" + realm + ":" + password)
|
||||
# print("HA1a:", HA1a.get_string_from_ascii())
|
||||
# #var HA1b:PackedByteArray = set_PackedByteArray(":" + nonce + ":" + cnonce)
|
||||
# #print("HA1b:", HA1b.hex_encode())
|
||||
# var HA1c:PackedByteArray = hash_md5(HA1a)
|
||||
# print("HA1c:", HA1c.hex_encode())
|
||||
# var HA1d:PackedByteArray = hash_md5(set_PackedByteArray(HA1c.hex_encode() + ":" + nonce + ":" + cnonce))
|
||||
# print("HA1d:", HA1d.hex_encode())
|
||||
# var method:String = "AUTHENTICATE:"
|
||||
# var HA2:PackedByteArray = PackedByteArray()
|
||||
# if qop == "auth":
|
||||
# HA2 = hash_md5(set_PackedByteArray(method + ":" + uri))
|
||||
# print("HA2:", HA2.hex_encode())
|
||||
# else:
|
||||
# # HA2 = MD5(method:digestURI:MD5(entityBody))
|
||||
# var entityBody:String = ""
|
||||
# var u:PackedByteArray = hash_md5(set_PackedByteArray(entityBody))
|
||||
# #var t1:PackedByteArray = set_PackedByteArray(method + ":" + uri + ":")
|
||||
# var t:PackedByteArray = set_PackedByteArray(method + ":" + uri + ":" + u.hex_encode())
|
||||
# HA2 = hash_md5(t)
|
||||
# #var i1:PackedByteArray = set_PackedByteArray(":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":")
|
||||
# var response:PackedByteArray = hash_md5(set_PackedByteArray(
|
||||
# HA1d.hex_encode() +
|
||||
# ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" +
|
||||
# HA2.hex_encode()))
|
||||
var ifrealm:String = ""
|
||||
if realm != "":
|
||||
ifrealm = ",realm=" + realm
|
||||
var msg: String = \
|
||||
"username=\"" + username + "\"" + \
|
||||
ifrealm + \
|
||||
",nonce=\"" + nonce + "\"" + \
|
||||
",cnonce=\"" + cnonce + "\"" + \
|
||||
",nc=" + nc + \
|
||||
",qop=" + qop + \
|
||||
",digest-uri=\"" + uri + "\"" + \
|
||||
",response=" + Z + \
|
||||
",charset=\"" + charset + "\""
|
||||
print(msg)
|
||||
return Marshalls.utf8_to_base64(msg)
|
||||
|
||||
|
||||
func negotiate_ssl_authenticate_digest_md5() -> bool:
|
||||
""" NE MARCHE PAS !!!!!! """
|
||||
send_msg_debug.emit("Stream: sending request for DIGEST-MD5 (step:%d)" % auhtentification_step)
|
||||
if auhtentification_step == 0:
|
||||
var request_sasl:String = "<auth" + \
|
||||
|
@ -646,6 +792,10 @@ func negotiate_ssl_authenticate_digest_md5() -> bool:
|
|||
var qop:String = ""
|
||||
var charset:String = ""
|
||||
var algorithm:String = ""
|
||||
var cnonce:String = ""
|
||||
var nc:String = "00000001"
|
||||
var username:String = account_name.split("@")[0]
|
||||
#var username:String = account_name
|
||||
print(str(tab))
|
||||
for item in tab:
|
||||
var tab2:Array = item.split("=")
|
||||
|
@ -663,7 +813,7 @@ func negotiate_ssl_authenticate_digest_md5() -> bool:
|
|||
algorithm = value
|
||||
print(key," = ", value)
|
||||
print(tmp, " ", qop, " ", charset, " ",nonce)
|
||||
if qop != "auth":
|
||||
if qop != "auth" and qop != "auth-int":
|
||||
send_msg_error.emit("Stream: Authenticate digest-md5, qop unknonw (%s)" % qop)
|
||||
return false
|
||||
if charset != "utf-8":
|
||||
|
@ -672,7 +822,83 @@ func negotiate_ssl_authenticate_digest_md5() -> bool:
|
|||
if algorithm != "md5-sess":
|
||||
send_msg_error.emit("Stream: Authenticate digest-md5, algorithm unknonw (%s)" % algorithm)
|
||||
return false
|
||||
print(tmp)
|
||||
for car in nonce:
|
||||
var v:String = listcar[randi() % listcar.length()]
|
||||
cnonce += v
|
||||
print(cnonce)
|
||||
var auth_account = digest_md5(username,password,realm,nonce, "xmpp/" + server_xmpp_name, qop, nc, cnonce, charset, algorithm)
|
||||
# print(tmp)
|
||||
# # username:String, password:String, realm:String, nonce:String, uri:String, qop:String, nc:String, cnonce:String, charset:String, algorithm:String) -> String:
|
||||
#
|
||||
# var serv_type:String = "xmpp"
|
||||
# #var HA1a:PackedStringArray = PackedStringArray([username ,":", realm , ":", password])
|
||||
# var HA1a:PackedByteArray = set_PackedByteArray(username + ":" + realm + ":" + password)
|
||||
#
|
||||
# #var titi = username + ":" + realm + ":" + password
|
||||
# #print("titi:", titi)
|
||||
# #HA1a.push_back(username + ":" + realm + ":" + password)
|
||||
# #var o1:PackedByteArray = set_PackedByteArray(username + ":" + realm + ":" + password)
|
||||
# #print("o1:", o1.get_string_from_ascii())
|
||||
# print("HA1a:", HA1a.hex_encode())
|
||||
# var HA1b:PackedByteArray = set_PackedByteArray(":" + nonce + ":" + cnonce)
|
||||
# print("HA1b:", HA1b.hex_encode())
|
||||
# var HA1c:PackedByteArray = hash_md5(set_PackedByteArray(HA1a.hex_encode()))
|
||||
# var HA1d:PackedByteArray = hash_md5(set_PackedByteArray(HA1c.hex_encode() + HA1b.hex_encode()))
|
||||
# var method:String = "AUTHENTICATE:"
|
||||
# var digest_uri:String = serv_type + "/" + server_xmpp_name
|
||||
# var HA2:PackedByteArray
|
||||
# if qop == "auth":
|
||||
# #var t:PackedByteArray = set_PackedByteArray(method + ":" + digest_uri)
|
||||
# HA2 = hash_md5(set_PackedByteArray(method + ":" + digest_uri))
|
||||
# else:
|
||||
# # HA2 = MD5(method:digestURI:MD5(entityBody))
|
||||
# var entityBody:String = ""
|
||||
# var u:PackedByteArray = hash_md5(set_PackedByteArray(entityBody))
|
||||
# #var t1:PackedByteArray = set_PackedByteArray(method + ":" + digest_uri + ":")
|
||||
# var t:PackedByteArray = set_PackedByteArray(method + ":" + digest_uri + ":" + u.hex_encode())
|
||||
# HA2 = hash_md5(t)
|
||||
# #var i1:PackedByteArray = set_PackedByteArray(":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":")
|
||||
# var response:PackedByteArray = hash_md5(set_PackedByteArray(
|
||||
# HA1d.hex_encode() +
|
||||
# ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" +
|
||||
# HA2.hex_encode()))
|
||||
# var ifrealm:String = ""
|
||||
# if realm != "":
|
||||
# ifrealm = ",realm=" + realm
|
||||
# var msg: PackedByteArray = set_PackedByteArray(
|
||||
# "username=\"" + username + "\"" +
|
||||
# ifrealm +
|
||||
# ",nonce=\"" + nonce + "\"" +
|
||||
# ",cnonce=\"" + cnonce + "\"" +
|
||||
# ",nc=" + nc +
|
||||
# ",qop=" + qop +
|
||||
# ",digest-uri=\"" + digest_uri + "\"" +
|
||||
# ",response=" + response.hex_encode() +
|
||||
# ",charset=\"" + charset + "\""
|
||||
# ) # + response
|
||||
## charset=utf-8,username="chris",realm="elwood.innosoft.com",
|
||||
## nonce="OA6MG9tEQGm2hh",nc=00000001,cnonce="OA6MHXh6VqTrRk",
|
||||
## digest-uri="imap/elwood.innosoft.com",
|
||||
## response=d388dad90d4bbd760a152321f2143af7,qop=auth
|
||||
# print("msg:", msg.get_string_from_ascii())
|
||||
## var msf2:PackedStringArray = PackedStringArray()
|
||||
## var mystring:String = 'username="rob",realm="cataclysm.cx",nonce="OA6MG9tEQGm2hh",cnonce="OA6MHXh6VqTrRk",nc=00000001,qop=auth,digest-uri="xmpp/cataclysm.cx",response=d388dad90d4bbd760a152321f2143af7,charset=utf-8,authzid="rob@cataclysm.cx/myResource"'.strip_edges()
|
||||
## msf2.push_back(mystring)
|
||||
## var sol:String = "dXNlcm5hbWU9InJvYiIscmVhbG09ImNhdGFjbHlzbS5jeCIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixjbm9uY2U9Ik9BNk1IWGg2VnFUclJrIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2NhdGFjbHlzbS5jeCIscmVzcG9uc2U9ZDM4OGRhZDkwZDRiYmQ3NjBhMTUyMzIxZjIxNDNhZjcsY2hhcnNldD11dGYtOCxhdXRoemlkPSJyb2JAY2F0YWNseXNtLmN4L215UmVzb3VyY2Ui"
|
||||
## print("---", "".join(msf2))
|
||||
## print("msf2:", Marshalls.raw_to_base64(msf2.to_byte_array()))
|
||||
## print("msf2:", Marshalls.utf8_to_base64("".join(msf2)))
|
||||
## print("msf2:", Marshalls.utf8_to_base64(mystring))
|
||||
## if sol != Marshalls.raw_to_base64(msf2.to_byte_array()):
|
||||
## print("********************************************** FAILED 1" )
|
||||
## if sol != Marshalls.utf8_to_base64(mystring):
|
||||
## print("********************************************** FAILED 2")
|
||||
## if sol != Marshalls.utf8_to_base64("".join(msf2)):
|
||||
## print("********************************************** FAILED 3")
|
||||
# var auth_account:String = Marshalls.utf8_to_base64(msg.get_string_from_ascii())
|
||||
var request_sasl:String = "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'" + \
|
||||
" >" + auth_account + "</response>"
|
||||
send_ssl_string(request_sasl)
|
||||
auhtentification_step += 1
|
||||
return true
|
||||
return false
|
||||
|
@ -699,7 +925,6 @@ func negotiate_ssl_sasl(authentication_methods : Array) -> bool:
|
|||
send_msg_error.emit("Impossible to authenticate (unknown protocol)")
|
||||
return false
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -962,3 +1187,102 @@ func remove_stream_header(text :String) -> String:
|
|||
# tcp_peer.disconnect_from_host()
|
||||
# set_process(false)
|
||||
# stream_status = StreamState.END
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
func analyze_stream(msg:String) -> void:
|
||||
partial_stanza += msg
|
||||
if partial_stanza.is_empty():
|
||||
return
|
||||
var complete_stanza = true
|
||||
while complete_stanza == true:
|
||||
var parser = XMLParser.new()
|
||||
if partial_stanza.length() == 0:
|
||||
return
|
||||
parser.open_buffer( set_PackedByteArray(partial_stanza) )
|
||||
|
||||
var element_name = ""
|
||||
var node_offset = 0
|
||||
|
||||
if parser.read() == OK and parser.get_node_type() == XMLParser.NODE_ELEMENT:
|
||||
element_name = parser.get_node_name()
|
||||
if parser.is_empty():
|
||||
node_offset = partial_stanza.length()
|
||||
if parser.read() == OK:
|
||||
node_offset = parser.get_node_offset()
|
||||
|
||||
while parser.read() == OK and node_offset == 0:
|
||||
if parser.get_node_type() == XMLParser.NODE_ELEMENT_END:
|
||||
if parser.get_node_name() == element_name:
|
||||
if parser.read() == OK:
|
||||
node_offset = parser.get_node_offset()
|
||||
else:
|
||||
node_offset = partial_stanza.length()
|
||||
|
||||
if node_offset > 0:
|
||||
# We have found a complete stanza.
|
||||
var new_stanza:String = partial_stanza.left(node_offset)
|
||||
if node_offset == partial_stanza.length():
|
||||
partial_stanza = ""
|
||||
else:
|
||||
partial_stanza = partial_stanza.right(-node_offset)
|
||||
#emit_signal("new_stanza", new_stanza)
|
||||
print("new_stanza:", new_stanza)
|
||||
else:
|
||||
complete_stanza = false
|
||||
|
||||
|
||||
func escape_html(msg:String) -> String:
|
||||
var tmp = msg
|
||||
tmp.replace("&", "&")
|
||||
tmp.replace("<", "<")
|
||||
tmp.replace(">", ">")
|
||||
tmp.replace("'", "'")
|
||||
tmp.replace("\"", """)
|
||||
return tmp
|
||||
|
||||
|
||||
func send_message_to_old(message, to):
|
||||
if xmpp_state != XMPPState.AUTHENTICATED:
|
||||
return
|
||||
var msg:String = "<message to='" + escape_html(to) + "' type='chat'>\n" + \
|
||||
" <body>" + escape_html(message) + "</body>\n" + \
|
||||
"</message>"
|
||||
send_ssl_string(msg)
|
||||
|
||||
|
||||
func send_message_to_1(message, to):
|
||||
if xmpp_state != XMPPState.AUTHENTICATED:
|
||||
return
|
||||
var msg:String = "<?xml version='1.0'?><stream:stream from='" + account_name + "' to='" + escape_html(to) + "' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>\n" + \
|
||||
"<message to='" + escape_html(to) + "' > <body>" + escape_html(message) + "</body>\n" + \
|
||||
"</message></stream:stream>"
|
||||
send_ssl_string(msg)
|
||||
|
||||
|
||||
func send_message_to(message, to):
|
||||
if xmpp_state != XMPPState.AUTHENTICATED:
|
||||
return
|
||||
var msg:String = "<?xml version='1.0'?><stream:stream from='" + account_name + "' to='" + escape_html(to) + "' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>\n" + \
|
||||
"<message > <body>" + escape_html(message) + "</body>\n" + \
|
||||
"</message></stream:stream>"
|
||||
send_ssl_string(msg)
|
||||
|
||||
|
||||
func start_stream():
|
||||
if xmpp_state != XMPPState.AUTHENTICATED:
|
||||
return
|
||||
var msg:String = "<?xml version='1.0'?>" + \
|
||||
"<stream:stream" + \
|
||||
" from='" + escape_html(account_name) + "'" + \
|
||||
" to='" + escape_html(server_xmpp_name) + "'" + \
|
||||
" version='1.0'" + \
|
||||
" xml:lang='en'" + \
|
||||
" xmlns='jabber:client'" + \
|
||||
" xmlns:stream='http://etherx.jabber.org/streams'>\n" + \
|
||||
"</stream:stream>"
|
||||
send_ssl_string(msg)
|
||||
xmpp_state = XMPPState.SENDED_START_STREAM
|
||||
|
|
12
client/Stream/chat.gd
Normal file
12
client/Stream/chat.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Window
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
Stream.send_message_to("coucou", "titi")
|
||||
#Stream.send_message_to("Art thou not Romeo, and a Montague?", "romeo@example.net")
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
55
client/Stream/chat.tscn
Normal file
55
client/Stream/chat.tscn
Normal file
|
@ -0,0 +1,55 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://becf5crej4o5v"]
|
||||
|
||||
[ext_resource type="Script" path="res://Stream/chat.gd" id="1_44t2b"]
|
||||
|
||||
[node name="chat" type="Window"]
|
||||
title = "Chat"
|
||||
initial_position = 1
|
||||
size = Vector2i(500, 500)
|
||||
always_on_top = true
|
||||
script = ExtResource("1_44t2b")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="World" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/World"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/TabContainer/World"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="TextEdit" type="TextEdit" parent="VBoxContainer/TabContainer/World"]
|
||||
custom_minimum_size = Vector2(0, 70)
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -8.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
text = "Exemple"
|
||||
placeholder_text = "Taper votre texte"
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://c688gu5xrshpg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b5ej7nfagdlmf" path="res://assets/root.glb" id="1_s8vvr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfxlsfc5tcnb2" path="res://assets/root.glb" id="1_s8vvr"]
|
||||
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_rf26g"]
|
||||
data = PackedVector3Array(20, -1, -20, -21, -1, 20, -21, -1, -20, 20, -1, -20, 20, -1, 20, -21, -1, 20, 20, -3, 20, -21, -1, 20, 20, -1, 20, 20, -3, 20, -21, -3, 20, -21, -1, 20, -21, -3, 20, -21, -1, -20, -21, -1, 20, -21, -3, 20, -21, -3, -20, -21, -1, -20, -21, -3, -20, 20, -3, 20, 20, -3, -20, -21, -3, -20, -21, -3, 20, 20, -3, 20, 20, -3, -20, 20, -1, 20, 20, -1, -20, 20, -3, -20, 20, -3, 20, 20, -1, 20, -21, -3, -20, 20, -1, -20, -21, -1, -20, -21, -3, -20, 20, -3, -20, 20, -1, -20)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@ config_version=5
|
|||
|
||||
config/name="Bazar d'Alea"
|
||||
run/main_scene="res://scenes/main.tscn"
|
||||
config/features=PackedStringArray("4.1", "Forward Plus")
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
|
|
@ -17,6 +17,7 @@ var player_name: String
|
|||
const player_path:String = "res://player/character.tscn"
|
||||
@export var PlayerCharacter = preload(player_path)
|
||||
@export var debug_window: PackedScene
|
||||
const chat_windows:String = "res://Stream/chat.tscn"
|
||||
|
||||
#@onready var _MainWindow: Window = get_window()
|
||||
|
||||
|
@ -39,6 +40,7 @@ func _ready():
|
|||
Stream.set_port_number(5222)
|
||||
Stream.send_msg_debug.connect(show_stream_debug)
|
||||
Stream.send_msg_error.connect(show_stream_error)
|
||||
Stream.chat_connected.connect(show_chat)
|
||||
#$Window.world_2d = _MainWindow.world_2d
|
||||
|
||||
|
||||
|
@ -50,6 +52,12 @@ func show_stream_error(msg:String):
|
|||
print("ERROR [Stream] ", msg)
|
||||
|
||||
|
||||
func show_chat():
|
||||
print("INFO [Stream] open")
|
||||
var new_window: Window = load(chat_windows).instantiate()
|
||||
add_child(new_window)
|
||||
|
||||
|
||||
func create_view_window():
|
||||
pass
|
||||
# var new_window: Window = view_window.instantiate()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cg5uqqd4ibdem"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bng6cjt7kq1hv" path="res://assets/player.glb" id="1_bpxp1"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm1b2g86hox0p" path="res://assets/player.glb" id="1_bpxp1"]
|
||||
[ext_resource type="Script" path="res://scenes/player.gd" id="1_br7n0"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_cjbav"]
|
||||
|
|
296
ejabberd.yml
Normal file
296
ejabberd.yml
Normal file
|
@ -0,0 +1,296 @@
|
|||
|
||||
###
|
||||
### ejabberd configuration file
|
||||
###
|
||||
### The parameters used in this configuration file are explained at
|
||||
###
|
||||
### https://docs.ejabberd.im/admin/configuration
|
||||
###
|
||||
### The configuration file is written in YAML.
|
||||
### *******************************************************
|
||||
### ******* !!! WARNING !!! *******
|
||||
### ******* YAML IS INDENTATION SENSITIVE *******
|
||||
### ******* MAKE SURE YOU INDENT SECTIONS CORRECTLY *******
|
||||
### *******************************************************
|
||||
### Refer to http://en.wikipedia.org/wiki/YAML for the brief description.
|
||||
###
|
||||
#docker run --name test -it \
|
||||
# -v $(pwd)/ejabberd.yml:/home/ejabberd/conf/ejabberd.yml \
|
||||
# --publish 5222:5222 \
|
||||
# --publish 5269:5269 \
|
||||
# --publish 5280:5280 \
|
||||
# --publish 5443:5443 \
|
||||
# --publish 1883:1883 \
|
||||
# ejabberd/ecs
|
||||
|
||||
hosts:
|
||||
- localhost
|
||||
|
||||
loglevel: debug
|
||||
log_rotate_size: 10485760
|
||||
log_rotate_date: ""
|
||||
log_rotate_count: 1
|
||||
log_rate_limit: 100
|
||||
|
||||
certfiles:
|
||||
- /home/ejabberd/conf/server.pem
|
||||
|
||||
ca_file: "/home/ejabberd/conf/cacert.pem"
|
||||
|
||||
## When using let's encrypt to generate certificates
|
||||
##certfiles:
|
||||
## - /etc/letsencrypt/live/localhost/fullchain.pem
|
||||
## - /etc/letsencrypt/live/localhost/privkey.pem
|
||||
##
|
||||
##ca_file: "/etc/letsencrypt/live/localhost/fullchain.pem"
|
||||
|
||||
listen:
|
||||
-
|
||||
port: 5222
|
||||
ip: "::"
|
||||
module: ejabberd_c2s
|
||||
max_stanza_size: 262144
|
||||
shaper: c2s_shaper
|
||||
access: c2s
|
||||
starttls_required: true
|
||||
-
|
||||
port: 5269
|
||||
ip: "::"
|
||||
module: ejabberd_s2s_in
|
||||
max_stanza_size: 524288
|
||||
-
|
||||
port: 5443
|
||||
ip: "::"
|
||||
module: ejabberd_http
|
||||
tls: true
|
||||
request_handlers:
|
||||
"/admin": ejabberd_web_admin
|
||||
"/api": mod_http_api
|
||||
"/bosh": mod_bosh
|
||||
"/captcha": ejabberd_captcha
|
||||
"/upload": mod_http_upload
|
||||
"/ws": ejabberd_http_ws
|
||||
"/oauth": ejabberd_oauth
|
||||
-
|
||||
port: 5280
|
||||
ip: "::"
|
||||
module: ejabberd_http
|
||||
request_handlers:
|
||||
"/admin": ejabberd_web_admin
|
||||
-
|
||||
port: 1883
|
||||
ip: "::"
|
||||
module: mod_mqtt
|
||||
backlog: 1000
|
||||
##
|
||||
## https://docs.ejabberd.im/admin/configuration/#stun-and-turn
|
||||
## ejabberd_stun: Handles STUN Binding requests
|
||||
##
|
||||
##-
|
||||
## port: 3478
|
||||
## ip: "0.0.0.0"
|
||||
## transport: udp
|
||||
## module: ejabberd_stun
|
||||
## use_turn: true
|
||||
## turn_ip: "{{ IP }}"
|
||||
## auth_type: user
|
||||
## auth_realm: "example.com"
|
||||
##-
|
||||
## port: 3478
|
||||
## ip: "0.0.0.0"
|
||||
## module: ejabberd_stun
|
||||
## use_turn: true
|
||||
## turn_ip: "{{ IP }}"
|
||||
## auth_type: user
|
||||
## auth_realm: "example.com"
|
||||
##-
|
||||
## port: 5349
|
||||
## ip: "0.0.0.0"
|
||||
## module: ejabberd_stun
|
||||
## certfile: "/home/ejabberd/conf/server.pem"
|
||||
## tls: true
|
||||
## use_turn: true
|
||||
## turn_ip: "{{ IP }}"
|
||||
## auth_type: user
|
||||
## auth_realm: "example.com"
|
||||
##
|
||||
## https://docs.ejabberd.im/admin/configuration/#sip
|
||||
## To handle SIP (VOIP) requests:
|
||||
##
|
||||
##-
|
||||
## port: 5060
|
||||
## ip: "0.0.0.0"
|
||||
## transport: udp
|
||||
## module: ejabberd_sip
|
||||
##-
|
||||
## port: 5060
|
||||
## ip: "0.0.0.0"
|
||||
## module: ejabberd_sip
|
||||
##-
|
||||
## port: 5061
|
||||
## ip: "0.0.0.0"
|
||||
## module: ejabberd_sip
|
||||
## tls: true
|
||||
|
||||
s2s_use_starttls: optional
|
||||
|
||||
acl:
|
||||
local:
|
||||
user_regexp: ""
|
||||
loopback:
|
||||
ip:
|
||||
- 127.0.0.0/8
|
||||
- ::1/128
|
||||
- ::FFFF:127.0.0.1/128
|
||||
admin:
|
||||
user:
|
||||
- "admin@localhost"
|
||||
|
||||
access_rules:
|
||||
local:
|
||||
allow: local
|
||||
c2s:
|
||||
deny: blocked
|
||||
allow: all
|
||||
announce:
|
||||
allow: admin
|
||||
configure:
|
||||
allow: admin
|
||||
muc_create:
|
||||
allow: local
|
||||
pubsub_createnode:
|
||||
allow: local
|
||||
trusted_network:
|
||||
allow: loopback
|
||||
|
||||
api_permissions:
|
||||
"console commands":
|
||||
from:
|
||||
- ejabberd_ctl
|
||||
who: all
|
||||
what: "*"
|
||||
"admin access":
|
||||
who:
|
||||
access:
|
||||
allow:
|
||||
acl: loopback
|
||||
acl: admin
|
||||
oauth:
|
||||
scope: "ejabberd:admin"
|
||||
access:
|
||||
allow:
|
||||
acl: loopback
|
||||
acl: admin
|
||||
what:
|
||||
- "*"
|
||||
- "!stop"
|
||||
- "!start"
|
||||
"public commands":
|
||||
who:
|
||||
ip: 127.0.0.1/8
|
||||
what:
|
||||
- status
|
||||
- connected_users_number
|
||||
|
||||
shaper:
|
||||
normal: 1000
|
||||
fast: 50000
|
||||
|
||||
shaper_rules:
|
||||
max_user_sessions: 10
|
||||
max_user_offline_messages:
|
||||
5000: admin
|
||||
100: all
|
||||
c2s_shaper:
|
||||
none: admin
|
||||
normal: all
|
||||
s2s_shaper: fast
|
||||
|
||||
max_fsm_queue: 10000
|
||||
|
||||
acme:
|
||||
contact: "mailto:example-admin@example.com"
|
||||
ca_url: "https://acme-staging-v02.api.letsencrypt.org/directory"
|
||||
|
||||
modules:
|
||||
mod_adhoc: {}
|
||||
mod_admin_extra: {}
|
||||
mod_announce:
|
||||
access: announce
|
||||
mod_avatar: {}
|
||||
mod_blocking: {}
|
||||
mod_bosh: {}
|
||||
mod_caps: {}
|
||||
mod_carboncopy: {}
|
||||
mod_client_state: {}
|
||||
mod_configure: {}
|
||||
mod_disco: {}
|
||||
mod_fail2ban: {}
|
||||
mod_http_api: {}
|
||||
mod_http_upload:
|
||||
put_url: https://@HOST@:5443/upload
|
||||
mod_last: {}
|
||||
mod_mam:
|
||||
## Mnesia is limited to 2GB, better to use an SQL backend
|
||||
## For small servers SQLite is a good fit and is very easy
|
||||
## to configure. Uncomment this when you have SQL configured:
|
||||
## db_type: sql
|
||||
assume_mam_usage: true
|
||||
default: never
|
||||
mod_mqtt: {}
|
||||
mod_muc:
|
||||
access:
|
||||
- allow
|
||||
access_admin:
|
||||
- allow: admin
|
||||
access_create: muc_create
|
||||
access_persistent: muc_create
|
||||
access_mam:
|
||||
- allow
|
||||
default_room_options:
|
||||
allow_subscription: true # enable MucSub
|
||||
mam: false
|
||||
mod_muc_admin: {}
|
||||
mod_offline:
|
||||
access_max_user_messages: max_user_offline_messages
|
||||
mod_ping: {}
|
||||
mod_privacy: {}
|
||||
mod_private: {}
|
||||
mod_proxy65:
|
||||
access: local
|
||||
max_connections: 5
|
||||
mod_pubsub:
|
||||
access_createnode: pubsub_createnode
|
||||
plugins:
|
||||
- flat
|
||||
- pep
|
||||
force_node_config:
|
||||
## Avoid buggy clients to make their bookmarks public
|
||||
storage:bookmarks:
|
||||
access_model: whitelist
|
||||
mod_push: {}
|
||||
mod_push_keepalive: {}
|
||||
mod_register:
|
||||
## Only accept registration requests from the "trusted"
|
||||
## network (see access_rules section above).
|
||||
## Think twice before enabling registration from any
|
||||
## address. See the Jabber SPAM Manifesto for details:
|
||||
## https://github.com/ge0rg/jabber-spam-fighting-manifesto
|
||||
ip_access: trusted_network
|
||||
mod_roster:
|
||||
versioning: true
|
||||
mod_sip: {}
|
||||
mod_s2s_dialback: {}
|
||||
mod_shared_roster: {}
|
||||
mod_stream_mgmt:
|
||||
resend_on_timeout: if_offline
|
||||
mod_vcard: {}
|
||||
mod_vcard_xupdate: {}
|
||||
mod_version:
|
||||
show_os: false
|
||||
|
||||
### Local Variables:
|
||||
### mode: yaml
|
||||
### End:
|
||||
### vim: set filetype=yaml tabstop=8
|
||||
|
|
@ -7,7 +7,7 @@ declare FORCE=0
|
|||
declare IMPORT=0
|
||||
declare ERASEIMPORT=0
|
||||
declare WORKDIR="$(dirname $(readlink -f $0))"
|
||||
declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/4.1.3/Godot_v4.1.3-stable_linux.x86_64.zip"
|
||||
declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/4.2.1/Godot_v4.2.1-stable_linux.x86_64.zip"
|
||||
declare OUTZIP="$WORKDIR/$(basename $GODOT_SRC)"
|
||||
declare CLIENTDIR="$WORKDIR/client"
|
||||
declare OPTION=""
|
||||
|
|
|
@ -26,7 +26,7 @@ then
|
|||
else
|
||||
docker start ejabberd
|
||||
docker logs -f ejabberd
|
||||
docker stop
|
||||
docker stop ejabberd
|
||||
fi
|
||||
|
||||
# https://localhost:5443/admin/
|
||||
|
@ -36,4 +36,6 @@ fi
|
|||
# docker exec -it ejabberd bin/ejabberdctl stats registeredusers
|
||||
# docker exec -it ejabberd bin/ejabberdctl register titi localhost titi
|
||||
# docker exec -it ejabberd bin/ejabberdctl register undefined localhost undefined
|
||||
# docker exec -it ejabberd bin/ejabberdctl help commands
|
||||
# docker exec -it ejabberd bin/ejabberdctl unban_ip 172.17.0.1
|
||||
|
||||
|
|
Loading…
Reference in a new issue