Loading

mIRC SASL

  1. /*
  2. mSASL Version 1.0 Beta [sans DLL] designed by Kyle Travaglini
  3. * To use this script you must have the proper DLL
  4. * All I ask is you leave the credit line within the main dialog
  5. * PLEASE read the SASLreadme.txt file before asking questions!
  6.  
  7.  
  8. [sans DLL changes] [wide] Screenshot https://cdn.pbrd.co/images/IYav5ZF.png
  9. Tested with versions 6.12, 6.35 and 7.19
  10. Should work with v6.03+ (when $input changed to letter flags)
  11.  
  12. how to guide w/ pictures if you need help: http://bit.ly/mirc-sasl-howto
  13.  
  14. - $dll call removed and replaced with scripted version [$SASL(username,password).plain]
  15. - $decode call removed and replaced with plain text [mIRC disables $decode by default]
  16. * a few other edits to fix bugs and add a bit more function
  17.  
  18. * only plain is supported for AuthType [blank defaults to plain]
  19. * auth timeout support added [blank defaults to 30 seconds]
  20.  
  21. * break up authenticate lines over 400 characters
  22. * fixed edit network dialog error
  23. - noticed I set the hash tables to binary, removed binary flag [you might lose your settings]
  24. * added checks for required network configuration information
  25. * in network configuration [if left empty]:
  26. *   Domain defaults to 0
  27. *   Real Name defaults to $fullname, if not empty, then *
  28. *   Timeout defaults to 30 seconds [as above]
  29. *   AuthType defaults to PLAIN [as above]
  30. *   Network must be filled in
  31. *   Username must be filled in
  32. *   NS Password must be filled in
  33.  
  34. * added check for nickname in use error, resend as $me_$rand(a, z)
  35. * fixed some dialog display errors
  36. * change from /quote to /raw
  37.  
  38. * added check for server list file
  39. *   fixes error when trying to load server list when you have not saved one
  40. * changed manager button text to clarify what they do
  41. */
  42.  
  43. alias mSASL.ver { return 1.0 }
  44. alias mSASL.version { return mSASL $+(v, $mSASL.ver) Beta [sans DLL] }
  45. alias mSASL {
  46.   var %cid = $1, %network = $2
  47.   if (%network isin $SASL(%network).nlist) {
  48.     if ($prop == timer) { return $+(.timer, mSASL.TimeOut., %cid, ., %network) }
  49.     elseif ($prop == timeout) {
  50.       if ($SASL(%network).status == Authenticating) { scid %cid .raw CAP END }
  51.     }
  52.   }
  53. }
  54. alias mSASL.show { dialog -m SASL.main SASL.main }
  55. alias f2 { mSASL.show }
  56. menu menubar,status {
  57.   -
  58.   $mSASL.version: mSASL.show
  59.   -
  60. }
  61.  
  62. alias shname { return SASL }
  63. alias shfile { return $+(", $scriptdir, SASL.hsh, ") }
  64. alias SASL {
  65.   if ($isid) {
  66.     if ($prop == nlist) { return $hget($shname, NLIST) }
  67.     if ($prop == timeout) { return $hget($shname, $+($1, :TIMEOUT)) }
  68.     if ($prop == user) { return $hget($shname, $+($1, :USER)) }
  69.     if ($prop == passwd) { return $hget($shname, $+($1, :PASSWD)) }
  70.     if ($prop == domain) { return $hget($shname, $+($1, :DOMAIN)) }
  71.     if ($prop == realname) { return $hget($shname, $+($1, :REALNAME)) }
  72.     if ($prop == status) { return $hget($shname, $+($1, :STATUS)) }
  73.     if ($prop == authtype) { return $hget($shname, $+($1, :AUTHTYPE)) }
  74.     if ($prop == plain) {
  75.       bset -t &auth 1 $1
  76.       bset -t &auth $calc( $bvar(&auth, 0) + 2 ) $1
  77.       bset -t &auth $calc( $bvar(&auth, 0) + 2 ) $2
  78.       var %len = $encode(&auth, mb)
  79.       return $bvar(&auth, 1, %len).text
  80.     }
  81.   }
  82. }
  83. alias sd { hadd -m $shname $+($1, :, $2) $3- }
  84.  
  85. on *:START:{
  86.   if (!$hget($shname)) { hmake $shname 50 }
  87.   if ($exists($shfile)) { hload $shname $shfile }
  88. }
  89. on *:EXIT:{
  90.   if (($hget($shname)) && ($hget($shname,0).item > 0)) { hsave $shname $shfile }
  91. }
  92.  
  93. on ^*:LOGON:*:{
  94.   if ($network isin $SASL($network).nlist) {
  95.     .raw CAP LS
  96.     .raw NICK $me
  97.     .raw USER $SASL($network).user $SASL($network).domain $server : $+ $SASL($network).realname
  98.     sd $network STATUS Connecting
  99.     haltdef
  100.   }
  101. }
  102. on *:CONNECT:{
  103.   if ($network isin $SASL($network).nlist) { sd $network STATUS Connected }
  104. }
  105. on *:DISCONNECT:{
  106.   if ($network isin $SASL($network).nlist) { sd $network STATUS Disconnected }
  107. }
  108.  
  109. raw CAP:& LS *:{
  110.   if ($network isin $SASL($network).nlist) {
  111.     .raw CAP REQ :multi-prefix sasl
  112.     var %t = $mSASL($cid, $network).timer
  113.     %t 1 $SASL($network).timeout noop $mSASL($cid, $network).timeout
  114.   }
  115. }
  116. raw CAP:& ACK *:{
  117.   if ($network isin $SASL($network).nlist) {
  118.     .raw AUTHENTICATE $SASL($network).authtype
  119.     sd $network STATUS Authenticating
  120.   }
  121. }
  122. raw AUTHENTICATE:+:{
  123.   if ($network isin $SASL($network).nlist) {
  124.     if ($lower($SASL($network).authtype) == plain) {
  125.       var %p = $SASL($SASL($network).user, $SASL($network).passwd).plain, %e
  126.       while ($len(%p) >= 400) {
  127.         var %e = $left(%p, 400), %p = $mid(%p, 401, 0)
  128.         .raw AUTHENTICATE %e
  129.       }
  130.       if ($len(%p)) { .raw AUTHENTICATE %p }
  131.       else { .raw AUTHENTICATE + }
  132.     }
  133.     else { .raw CAP END }
  134.     haltdef
  135.   }
  136. }
  137. raw *:*:{
  138.   if ($network isin $SASL($network).nlist) {
  139.     if ($numeric isnum 903) {
  140.       .raw CAP END
  141.       sd $network STATUS Authenticated
  142.       var %t = $mSASL($cid, $network).timer
  143.       %t off
  144.     }
  145.     elseif ($numeric isnum 904-907) { .raw CAP END }
  146.     elseif ($numeric isnum 433) {
  147.       if ($istokcs(Connecting Authenticating Authenticated, $SASL($network).status, 32)) {
  148.         var %nick_temp = $me $+ _ $+ $rand(a, z)
  149.         echo -setc Info * SASL: Nickname is already in use. Falling back to %nick_temp
  150.         .raw NICK %nick_temp
  151.         .raw USER $SASL($network).user $SASL($network).domain $server : $+ $SASL($network).realname
  152.         haltdef
  153.       }
  154.     }
  155.   }
  156. }
  157.  
  158. dialog SASL.main {
  159.   title "SASL Manager"
  160.   size -1 -1 150 145
  161.   option dbu
  162.   box "Server List" 1, 5 3 140 113
  163.   text "Created by Kyle Travaglini" 3, 40 135 65 12
  164.   list 4, 10 13 80 104, vsbar, edit
  165.   button "Add Entry" 5, 96 13 43 12
  166.   button "Edit Entry" 6, 96 30 43 12
  167.   button "Delete Entry" 7, 96 47 43 12
  168.   button "Save List" 10, 96 64 43 12
  169.   button "Load List" 11, 96 81 43 12
  170.   button "OK" 8, 27 120 43 12, ok
  171.   button "Update SASL" 9, 77 120 43 12
  172. }
  173.  
  174. dialog SASL.edit {
  175.   title "Network Configuration"
  176.   size -1 -1 200 120
  177.   option dbu
  178.   box "Network Settings" 1, 5 3 190 97
  179.   text "Network:" 2, 10 13 36 10, right
  180.   edit "" 3, 48 12 122 10
  181.   text "Username:" 4, 10 25 36 10, right
  182.   edit "" 5, 48 24 122 10
  183.   text "NS Password:" 6, 10 37 36 10, right
  184.   edit "" 7, 48 36 122 10
  185.   text "Domain:" 8, 10 49 36 10, right
  186.   edit "" 9, 48 48 122 10
  187.   text "Real Name:" 10, 10 61 36 10, right
  188.   edit "" 11, 48 60 122 10
  189.   text "Timeout:" 12, 10 73 36 10, right
  190.   edit "" 13, 48 72 122 10
  191.   text "AuthType:" 14, 10 85 36 10, right
  192.   edit "" 15, 48 84 122 10
  193.   button "OK" 16, 57 105 43 12, ok
  194.   button "Cancel" 17, 107 105 43 12, cancel
  195. }
  196.  
  197. dialog SASL.deletewarn {
  198.   title "SASL"
  199.   size -1 -1 120 40
  200.   option dbu
  201.   text "You must specify a network to delete." 1, 13 5 100 10
  202.   button "OK" 2, 40 20 43 12, ok
  203. }
  204.  
  205. dialog SASL.editwarn {
  206.   title "SASL"
  207.   size -1 -1 120 40
  208.   option dbu
  209.   text "You must specify a network to edit." 1, 13 5 100 10
  210.   button "OK" 2, 40 20 43 12, ok
  211. }
  212.  
  213. on *:DIALOG:SASL.*:*:*:{
  214.   if ($dname == SASL.main) {
  215.     if ($devent == init) {
  216.       did -r $dname 3
  217.       did -a $dname 3 Created by Kyle Travaglini
  218.       didtok $dname 4 44 $SASL($network).nlist
  219.       ;// disable 'Update SASL' button
  220.       did -b $dname 9
  221.     }
  222.     if ($devent == sclick) {
  223.       if ($did == 5) {
  224.         if ($hget($shname, EDIT) == True) {
  225.           hdel $shname EDIT
  226.           hdel $shname EDITn
  227.         }
  228.         dialog -m SASL.edit SASL.edit
  229.       }
  230.       elseif ($did == 6) {
  231.         if ($did($dname, 4).seltext) {
  232.           hadd -m $shname EDIT True
  233.           hadd -m $shname EDITn $did($dname, 4).seltext
  234.           dialog -m SASL.edit SASL.edit
  235.         }
  236.         else { dialog -m SASL.editwarn SASL.editwarn }
  237.       }
  238.       elseif ($did == 7) {
  239.         if ($did($dname, 4).sel) {
  240.           if ($?!="Are you certain you wish to delete $did($dname, 4).seltext $+ ?") {
  241.             hdel -w $shname $+($did($dname, 4).seltext, :*)
  242.             hadd -m $shname NLIST $remtok($SASL($network).nlist, $did($dname, 4).seltext, 1, 44)
  243.             did -d $dname 4 $did($dname, 4).sel
  244.           }
  245.         }
  246.         else { dialog -m SASL.deletewarn SASL.deletewarn }
  247.       }
  248.       elseif ($did == 9) { usasl }
  249.       elseif ($did == 10) {
  250.         if (($hget($shname)) && ($hget($shname,0).item > 0)) { hsave $shname $shfile }
  251.       }
  252.       elseif ($did == 11) {
  253.         if ($exists($shfile)) {
  254.           if (!$hget($shname)) { hmake $shname 50 }
  255.           hload $shname $shfile
  256.           did -r $dname 4
  257.           didtok $dname 4 44 $SASL($network).nlist
  258.         }
  259.         else {
  260.           .echo -q $input(No file to load, ohu)
  261.         }
  262.       }
  263.     }
  264.   }
  265.   elseif ($dname == SASL.edit) {
  266.     if ($devent == init) {
  267.       if ($hget($shname, EDIT) == True) {
  268.         var %network = $did(SASL.main, 4).seltext
  269.         did -a $dname 3 %network
  270.         did -a $dname 5 $SASL(%network).user
  271.         did -a $dname 7 $SASL(%network).passwd
  272.         did -a $dname 9 $SASL(%network).domain
  273.         did -a $dname 11 $SASL(%network).realname
  274.         did -a $dname 13 $SASL(%network).timeout
  275.         did -a $dname 15 $SASL(%network).authtype
  276.       }
  277.     }
  278.     if ($devent == sclick) {
  279.       if ($did == 16) {
  280.         var %network = $did($dname, 3), %user = $did($dname, 5), %passwd = $did($dname, 7)
  281.         if ((!%network) || (%network == network name needed)) {
  282.           if (!%network) { did -a $dname 3 network name needed }
  283.           halt
  284.         }
  285.         if ((!%user) || (%user == username name needed)) {
  286.           if (!%user) { did -a $dname 5 username name needed }
  287.           halt
  288.         }
  289.         if ((!%passwd) || (%passwd == password name needed)) {
  290.           if (!%passwd) { did -a $dname 7 password name needed }
  291.           halt
  292.         }
  293.         if ($hget($shname, EDIT) == True) { hadd -m $shname NLIST $remtok($SASL($network).nlist, %network, 1, 44) }
  294.         else {
  295.           if ($findtok($SASL($network).nlist, %network, 1, 44)) {
  296.             if ($?!=" $+ %network already exists; overwrite?") {
  297.               hadd -m $shname NLIST $remtok($SASL($network).nlist, %network, 1, 44)
  298.             }
  299.             else { halt }
  300.           }
  301.         }
  302.         if ($hget($shname, EDIT) == True) && ($hget($shname, EDITn) != %network) {
  303.           if ($?!="rename $hget($shname, EDITn) to %network $+ ?") {
  304.             hdel -w $shname $+($hget($shname, EDITn), :*)
  305.             hadd -m $shname NLIST $remtok($SASL($network).nlist, $hget($shname, EDITn), 1, 44)
  306.           }
  307.           else { halt }
  308.         }
  309.         hdel $shname EDIT
  310.         hdel $shname EDITn
  311.         hadd -m $shname NLIST $+($SASL($network).nlist, $chr(44), %network)
  312.         sd %network USER $did($dname, 5)
  313.         sd %network PASSWD $did($dname, 7)
  314.         sd %network DOMAIN $iif($did($dname, 9), $v1, 0)
  315.         sd %network REALNAME $iif($did($dname, 11), $v1, $iif($fullname, $v1, *))
  316.         sd %network TIMEOUT $iif($did($dname, 13), $v1, 30)
  317.         sd %network AUTHTYPE $iif($did($dname, 15), $upper($v1), PLAIN)
  318.         did -r SASL.main 4
  319.         didtok SASL.main 4 44 $SASL($network).nlist
  320.       }
  321.     }
  322.   }
  323. }
  324. ;;

Version history

Revision # Author Created at
pjpgfcfoz Anonymous 29 Jan 2015, 18:24:40 UTC Diff

Comments