File tree 6 files changed +54
-11
lines changed
6 files changed +54
-11
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,12 @@ l_s_logger equ $ - s_logger
43
43
44
44
; null terminated C strings
45
45
46
+ c_invalid_length_ddnet_only db "error: got unexpected packet length for 0.6 connection. Only servers with ddnet security tokens are supported in 0.6" , 0x00
46
47
c_connect6 db "connecting using 0.6 ddnet protocol to " , 0x00
47
48
c_connect7 db "connecting using 0.7 protocol to " , 0x00
48
49
c_map_change db "got map change. new map: " , 0x00
49
50
c_motd db "motd" , 0x00
50
51
c_ch at db "chat" , 0x00
51
52
c_broadcast db "broadcast" , 0x00
52
53
c_client db "client" , 0x00
54
+ c_error db "error" , 0x00
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ MSG_CTRL_TOKEN equ 5
11
11
MSG6_CTRL_KEEPALIVE equ 0
12
12
MSG6_CTRL_CONNECT equ 1
13
13
MSG6_CTRL_CONNECTACCEPT equ 2
14
- ; MSG6_CTRL_ACCEPT equ 3 ; UNUSED!
14
+ MSG6_CTRL_ACCEPT equ 3
15
15
MSG6_CTRL_CLOSE equ 4
16
16
17
17
MSG_SYSTEM_NULL equ 0
Original file line number Diff line number Diff line change 1
1
; vim: set tabstop=4:softtabstop=4:shiftwidth=4
2
2
; vim: set expandtab:
3
3
4
+ throw_c_str:
5
+ ; throw_c_str [rax]
6
+ ; rax = null terminated string with error message
7
+ ; logs with log level error and terminates the process
8
+ mov r9 , rax
9
+ mov rax , c_error
10
+ mov rdi , r9
11
+ call log_error
12
+ exit 1
13
+ ret
14
+
4
15
build_log_line:
5
16
; log_info [rax]
6
17
; rax = null terminated label
@@ -78,6 +89,13 @@ log_info:
78
89
pop_registers
79
90
ret
80
91
92
+ log_error:
93
+ ; log_error [rax]
94
+ ; rax = null terminated label
95
+ ; rdi = null terminated string
96
+ call log_info
97
+ ret
98
+
81
99
log_debug:
82
100
; log_debug [rax]
83
101
; rax = null terminated label
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ send_packet6:
75
75
call set_packet_header
76
76
77
77
; append ddnet security token at the end of all packet payloads
78
- packet6_pack_raw token , 4
78
+ packet6_pack_raw peer_token , 4
79
79
80
80
; buf
81
81
mov rax , udp_send_buf
Original file line number Diff line number Diff line change 1
1
on_ctrl6_msg_connect_accept:
2
- ; ignore cursed token only ddnet servers send
3
- ; https://github.com/ddnet/ddnet/issues/8805
2
+ ; in addition to checking the length
3
+ ; we could also check for the "TKEN"
4
+ ; magic in front of the token
4
5
5
- ; mov rax, [udp_recv_buf + 8]
6
- ; mov [peer_token], rax
6
+ mov eax , dword [ udp_read_len ]
7
+ cmp eax , 12
8
+ je .len_ok
9
+ mov rax , c_invalid_length_ddnet_only
10
+ call throw_c_str
11
+ .len_ok:
12
+
13
+ mov rax , [ udp_recv6_buf + PACKET6_HEADER_LEN + 5 ]
14
+ mov [ peer_token ], eax
15
+ print_label s_got_peer_token
16
+ mov rax , peer_token
17
+ mov rdi , 4
18
+ call print_hexdump
19
+ call print_newline
7
20
8
21
print_label s_got_accept
22
+ call send_ctrl6_msg_ack_accept
9
23
; call send_msg_info
10
24
11
25
jmp on_ctrl6_message_end
Original file line number Diff line number Diff line change @@ -30,12 +30,8 @@ send_ctrl_close:
30
30
send_ctrl_msg_connect6:
31
31
push rax
32
32
33
- mov byte [ token + 0 ], 0xff
34
- mov byte [ token + 1 ], 0xff
35
- mov byte [ token + 2 ], 0xff
36
- mov byte [ token + 3 ], 0xff
37
33
38
- packet6_pack_byte MSG_CTRL_CONNECT
34
+ packet6_pack_byte MSG6_CTRL_CONNECT
39
35
packet6_pack_raw MAGIC_TKEN , 4
40
36
41
37
mov byte [ out_packet_header_flags ], PACKETFLAG6_CONTROL
@@ -45,6 +41,19 @@ send_ctrl_msg_connect6:
45
41
pop rax
46
42
ret
47
43
44
+ send_ctrl6_msg_ack_accept:
45
+ push rax
46
+
47
+ packet6_pack_byte MSG6_CTRL_ACCEPT
48
+ ; packet6_pack_raw [peer_token], 4
49
+
50
+ mov byte [ out_packet_header_flags ], PACKETFLAG6_CONTROL
51
+ mov byte [ out_packet_header_num_chunks ], 0
52
+ call send_packet
53
+
54
+ pop rax
55
+ ret
56
+
48
57
send_ctrl_msg_connect:
49
58
push rax
50
59
mov al , byte [ connection_version ]
You can’t perform that action at this time.
0 commit comments