-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket.etcl
executable file
·106 lines (105 loc) · 6.44 KB
/
socket.etcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
proc listen_command {idx} {
global set
control $idx socket_command
putcmdlog "> Accepted DCC connection from: [lindex [replace [findidx $idx] @ " "] 3]"
putdcc $idx "001 Please authenticate with: nickname handle password \[command\]"
}
proc socket_command {idx text} {
global set botnick
set nick [lindex $text 0]
set handle [lindex $text 1]
set pass [lindex $text 2]
set command [string tolower [lindex $text 3]]
set data [lrange $text 4 end]
set return 0
if {$text == ""} {
return
} elseif {$nick == ""} {
putdcc $idx "002 You did not specify a nickname."
} elseif {$handle == ""} {
putdcc $idx "002 You did not specify a handle."
} elseif {$pass == ""} {
putdcc $idx "002 You did not specify a password."
} elseif {![validuser $handle]} {
putdcc $idx "002 You do not have access to any commands."
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) tried to authenticate but are unrecognized?!"
}
} elseif {[nickinfo $handle pass] == ""} {
putdcc $idx "002 You have not yet set a password."
} elseif {[getchanhost $nick] == ""} {
putdcc $idx "002 Your nickname ($nick) could not be located on any channels I monitor."
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[can't find userhost\]"
}
} elseif {[string tolower [nick2hand $nick]] != [string tolower $handle] && [nick2hand $nick] != "*"} {
putdcc $idx "002 Your nickname ($nick) is known as [nick2hand $nick] not $handle."
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[wrong handle\]"
}
} elseif {![passwdok $handle $pass]} {
putdcc $idx "002 Password mismatch for $handle"
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])): failed authentication, wrong password"
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[wrong password\]"
}
} elseif {[nick2hand $nick] == "*"} {
if {[passwdok $handle $pass] && [llength [getuser $handle HOSTS]] >= $set(maxhosts)} {
putdcc $idx "002 Password Accepted -- Unfortunately you have no userhost slots left. Authentication failed"
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])): passed authentication, no userhost slots left - authentication failed"
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[no userhost slots left\]"
}
} elseif {[passwdok $handle $pass]} {
putdcc $idx "Password Accepted -- You have been authenticated as $handle \[userhosts updated\]"
set return 1
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
if {[llength [notelist $handle new]] > "0"} {
putdcc $idx "You have a total of [llength [notelist $handle all]] notes ([llength [notelist $handle new]] unread, [llength [notelist $handle old]] read)"
putdcc $idx "Type: \002/msg $botnick list\002 or \002/msg $botnick list new\002"
}
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])): successfully authenticated as '$handle' and userhosts updated"
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[passed/userhosts updated\]"
setuser $handle HOSTS [maskhost $nick![getchanhost $nick]]
setuser $handle XTRA USERHOST [getchanhost $nick]
setuser $handle XTRA REALHOST [lindex [replace [findidx $idx] @ " "] 3]
setuser $handle XTRA AUTH 1
auth_automode $nick $handle [getchanhost $nick]
}
}
} elseif {[passwdok $handle $pass]} {
putdcc $idx "Password Accepted -- You have been authenticated as $handle"
set return 1
if {($command == "" && [nickinfo $handle auth]) || ![nickinfo $handle auth]} {
if {[llength [notelist $handle new]] > "0"} {
putdcc $idx "You have a total of [llength [notelist $handle all]] notes ([llength [notelist $handle new]] unread, [llength [notelist $handle old]] read)"
putdcc $idx "Type: \002/msg $botnick list\002 or \002/msg $botnick list new\002"
}
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])): successfully authenticated"
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) AUTH\[s\] \[passed\]"
setuser $handle XTRA USERHOST [getchanhost $nick]
setuser $handle XTRA REALHOST [lindex [replace [findidx $idx] @ " "] 3]
setuser $handle XTRA AUTH 1
auth_automode $nick $handle [getchanhost $nick]
}
}
if {$command != "" && !$return} {
killdcc $idx
return
} elseif {$command != "" && [getchanhost $nick] != [nickinfo $handle userhost]} {
putdcc $idx "002 You are using the wrong user@host on nickname"
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) COMMAND\[s\] \[tried '$command' but are using the wrong userhost\]"
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) tried '$command' but is using the wrong userhost?"
} elseif {$command != "" && ![nickinfo $handle auth]} {
putdcc $idx "002 You are not yet authenticated."
putcmdlog "> !$handle! ($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) COMMAND\[s\] \[tried '$command' but is not authenticated\]"
homechan "\[$handle\]($nick![getchanhost $nick] ([lindex [replace [findidx $idx] @ " "] 3])) tried '$command' but is not authenticated?"
} elseif {$command != "" && $command == "listban"} {
dcc_listban $handle $idx $data
} elseif {$command != "" && $command == "access"} {
dcc_access $handle $idx $data
} elseif {$command != ""} {
putdcc $idx "002 $command isn't a valid command."
}
killdcc $idx
}