Amélioration d'un script pour le rendre plus performant
#1
Hello à tous,

j'ai besoin d'optimiser un script pour le rendre plus performant :

tcl
# Regexp connection user 
set ::checkpays::regexpclientco {:\ (.*)\ \((.*?)@(.*?)\) \[(.*?)\] \[vhost: (.*?)\] (.*)\ \[country: (.*?)\] \[asn: (.*?)\] \[asname: (.*?)\] \[reputation: (.*?)\] (.+)}

# Realname age sexe
set ::checkpays::regexpagesex {^\d{1,2} [HFM]( .+)?}

# regexp pour match les ados de 12 à 17ans
set ::checkpays::regexpado {(1[2-7]) (H|F|M)}

############################################
#        PROC TRAITEMENT CONNECTING        #
############################################
 
proc ::checkpays::who:co {from keyword text} {
 
	if {![string match -nocase "*Client connecting*" $text]} {
		return;
	}
 
	set sslco 0
	set webirc 0
	set websocket 0
	set unknow 0
	set account 0
 
	regexp $::checkpays::regexpclientco $text - nick username ip ipdns vhost csa codepays asn asname reputation other

	# IP Except
	if {$ip eq "127.0.0.1" || [isbotnick $nick]} {
		return
	}
 
	set SESSION [md5 "${username}@${vhost}"]
 
	if {[string match -nocase "*tls-users*" $other]} {
		set sslco 1
	}
 
	if {[string match -nocase "*webirc-users*" $other]} {
		set webirc 1
	}
 
	if {[string match -nocase "*websocket-users*" $other]} {
		set websocket 1
	}
 
	if {[string match -nocase "*unknown-users*" $other]} {
		set unknow 1
	}
 
	if {[string match -nocase "*account:*" $csa]} {
		set account 1
	}

	# On met en mémoire les valeurs qu'on ne récupère pas dans le who
	set ::checkpays::DB($SESSION,IP) $ip
	set ::checkpays::DB($SESSION,IPDNS) $ipdns
	set ::checkpays::DB($SESSION,CODEPAYS) $codepays
	set ::checkpays::DB($SESSION,ASN) $asn
	set ::checkpays::DB($SESSION,ASNAME) $asname
	set ::checkpays::DB($SESSION,REPUTATION) $reputation
	set ::checkpays::DB($SESSION,SSLCO) $sslco
	set ::checkpays::DB($SESSION,WEBIRC) $webirc
	set ::checkpays::DB($SESSION,WEBSOCKET) $websocket
	set ::checkpays::DB($SESSION,UNKNOW) $unknow
	set ::checkpays::DB($SESSION,ACCOUNT) $account
 
	putnow "WHO $nick %unhr"
 
}
 
proc ::checkpays::who:gestion {from key text} {
 
   	set text [split [string trim $text]]
	lassign $text {} username vhost nick
	set SESSION [md5 "${username}@${vhost}"]
	set realname [join [lrange [split $text {:}] 1 end]]

	## On recupere les variables en mémoire
	set ip $::checkpays::DB($SESSION,IP)
	set ipdns $::checkpays::DB($SESSION,IPDNS)
	set sslco $::checkpays::DB($SESSION,SSLCO)
	set webirc $::checkpays::DB($SESSION,WEBIRC)
	set websocket $::checkpays::DB($SESSION,WEBSOCKET)
	set reputation $::checkpays::DB($SESSION,REPUTATION)
	set codepays $::checkpays::DB($SESSION,CODEPAYS)
	set asn $::checkpays::DB($SESSION,ASN)
	set asname $::checkpays::DB($SESSION,ASNAME)
	set unknow $::checkpays::DB($SESSION,UNKNOW)
	set account $::checkpays::DB($SESSION,ACCOUNT)

	# Nick/Ip/Ident EXCEPTION
	if {[::toolsAmand::verify:b $::checkpays::fichier(ident) $username]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - IDENT\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		return
 
	} elseif {[::toolsAmand::verify:b $::checkpays::fichier(pseudo) $nick]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - PSEUDO\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		return
 
	} elseif {[::toolsAmand::verify:b $::checkpays::fichier(ip) $ip]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - IP\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		return
 
	} else {
 
	}

	# On envoie à la proc de traitement
	::checkpays::traitement $nick $username $ip $ipdns $vhost $codepays $asn $asname $reputation $sslco $webirc $websocket $unknow $realname $account

	# Changement du realname en ASV / Redirection ados
	if {[regexp $::checkpays::regexpagesex $realname] != 1} {
 
		putnow "CHGNAME $nick [expr 18 + int(rand()*72)] M"
		putnow "PRIVMSG $::checkpays::backpaysredirect :\002\00300,02REALNAME\003\002 - \002$nick\002 \[$codepays\] ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Account: $account) (Asn: $asn) (Asname: $asname) vient d'être changé. Realname: $realname"
 
	} elseif {[regexp $::checkpays::regexpado $realname] == 1} {
 
		putnow "PRIVMSG OperServ :SVSJOIN $nick $::checkpays::salonado"
		putnow "SAUMODE $nick +R"
		#putnow "PRIVMSG $::checkpays::backpaysredirect :\002\0030,6ADO\002\003 - \002$nick\002 ($username@$ip) a été redirigé sur \002$::checkpays::salonado\002 - \002Realname:\002 $realname"
 
	} else {
 
	}
 
}
 
proc ::checkpays::traitement {nick username ip ipdns vhost codepays asn asname reputation sslco webirc websocket unknow realname account} {
 
	set SESSION [md5 "${username}@${vhost}"]
	set ALLEXCEPTIONS [list {*}$::checkpays::PAYSINTERDIT {*}$::checkpays::PAYSINTERDITNWSI {*}$::checkpays::PAYSINTERDITNW {*}$::checkpays::PAYSIPAPI {*}$::checkpays::PAYSEXCEPTION]
	set sanction 0

 
	# IP-API

	# Bloquer IPAPI Proxy/Hosting - IPABUSEIPDB
	if {[lsearch $::checkpays::PAYSIPAPI $codepays]!=-1} {
		::checkpays::infoAPI $nick $username $ip $ipdns $unknow $reputation $realname $webirc $websocket $account
	}

	# Traitement
	if {[lsearch $::checkpays::PAYSINTERDIT $codepays] != -1} {
 
		set sanction 1
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,4PAYS BLOQUÉ\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
 
	} elseif {([lsearch $::checkpays::PAYSINTERDITNWSI $codepays] != -1) && ($webirc == 0) && ($websocket == 0) && ($reputation < 200)} {
 
		set sanction 1
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,12PAYS BLOQUÉ - HORS WEB|RÉPUTATION\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
 
	} elseif {([lsearch $::checkpays::PAYSINTERDITNW $codepays] != -1) && ($webirc == 0) && ($websocket == 0)} {
 
		set sanction 1
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,6PAYS BLOQUÉ - HORS WEB\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
 
	} elseif {($codepays eq "US") || ([string match "*.irccloud.com" $ip])} {
 
		set sanction 1
		putnow "GLINE $username@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,10IRCCloud|US\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
 
	} else {
 
		# Si on entre pas dans une condition blacklisté on envoie à la proc du monitoring
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
 
	}

	# Vérification si le codepays est hors liste interdit/protégé
	if {[lsearch $ALLEXCEPTIONS $codepays]==-1} {
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,14USER SUSPECT\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::infoAPI $nick $username $ip $ipdns $unknow $reputation $realname $webirc $websocket $account
		::checkpays::infoABUSEIPDB $nick $username $ipdns
	}

	# Suppression des valeurs en mémoire.
	# https://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tcl/unset.n.html
	unset ::checkpays::DB($SESSION,IP)
	unset ::checkpays::DB($SESSION,IPDNS)
	unset ::checkpays::DB($SESSION,REPUTATION)
	unset ::checkpays::DB($SESSION,SSLCO)
	unset ::checkpays::DB($SESSION,WEBIRC)
	unset ::checkpays::DB($SESSION,CODEPAYS)
	unset ::checkpays::DB($SESSION,WEBSOCKET)
	unset ::checkpays::DB($SESSION,ASN)
	unset ::checkpays::DB($SESSION,ASNAME)
	unset ::checkpays::DB($SESSION,UNKNOW)
	unset ::checkpays::DB($SESSION,ACCOUNT)
 
	if {$sanction == 1} {
		return
	}
 
}



Il manque des variables/fonctions, j'ai mis les lignes essentiels pour faire un focus sur la problématique et de la partie qui doit être optimiser.

Il est fonctionnel, mais je pense qu'on peut faire largement mieux pour le rendre plus fluide , si vous avez des idées, welcome.
Répondre
#2
Grâce à CrazyCat sur le channel irc #eggdrop , j'ai pu apporter pas mal d'améliorations :

tcl
proc ::checkpays::who:co {from keyword text} {
 
	if {![string match -nocase "*Client connecting*" $text]} {
		return;
	}
 
	set sslco 0
	set webirc 0
	set websocket 0
	set unknow 0
	set account 0
 
	regexp $::checkpays::regexpclientco $text - nick username ip ipdns vhost csa codepays asn asname reputation other

	# IP Except
	if {$ip eq "127.0.0.1" || [isbotnick $nick]} {
		return
	}
 
	set SESSION [md5 "${username}@${vhost}"]
 
	if {[string match -nocase "*tls-users*" $other]} {
		set sslco 1
	}
 
	if {[string match -nocase "*webirc-users*" $other]} {
		set webirc 1
	}
 
	if {[string match -nocase "*websocket-users*" $other]} {
		set websocket 1
	}
 
	if {[string match -nocase "*unknown-users*" $other]} {
		set unknow 1
	}
 
	if {[string match -nocase "*account:*" $csa]} {
		set account 1
	}

	# On met en mémoire les valeurs qu'on ne récupère pas dans le who
 
	set ::checkpays::DB($SESSION) [list $ip $ipdns $codepays $asn $asname $reputation $sslco $webirc $websocket $unknow $account]
 
	putlog "who => $::checkpays::DB($SESSION)"
 
	putnow "WHO $nick %unhr"
 
}
 
proc ::checkpays::who:gestion {from key text} {
 
   	set text [split [string trim $text]]
	lassign $text {} username vhost nick
	set SESSION [md5 "${username}@${vhost}"]
	set realname [join [lrange [split $text {:}] 1 end]]

	## On recupere les variables en mémoire
 
	lassign $::checkpays::DB($SESSION) ip ipdns codepays asn asname reputation sslco webirc websocket unknow account
 
	putlog "gestion => $::checkpays::DB($SESSION)"

	# Nick/Ip/Ident EXCEPTION
	if {[::toolsAmand::verify:b $::checkpays::fichier(ident) $username]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - IDENT\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		unset ::checkpays::DB($SESSION)
		return
 
	} elseif {[::toolsAmand::verify:b $::checkpays::fichier(pseudo) $nick]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - PSEUDO\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		unset ::checkpays::DB($SESSION)
		return
 
	} elseif {[::toolsAmand::verify:b $::checkpays::fichier(ip) $ip]} {
 
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,3EXCEPTION - IP\003\002 \002\[\002$codepays\002\]\002 - $nick ($username@$ip) (Réputation: $reputation) (Sslco: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
		unset ::checkpays::DB($SESSION)
		return
 
	}

	# On envoie à la proc de traitement
	::checkpays::traitement $nick $username $ip $ipdns $vhost $codepays $asn $asname $reputation $sslco $webirc $websocket $unknow $realname $account

	# Changement du realname en ASV
	if {[regexp $::checkpays::regexpagesex $realname] != 1} {
 
		putnow "CHGNAME $nick [expr 18 + int(rand()*72)] M"
		putnow "PRIVMSG $::checkpays::backpaysredirect :\002\00300,02REALNAME\003\002 - \002$nick\002 \[$codepays\] ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Account: $account) (Asn: $asn) (Asname: $asname) vient d'être changé. Realname: $realname"
 
	} elseif {[regexp $::checkpays::regexpado $realname] == 1} {
 
		putnow "PRIVMSG OperServ :SVSJOIN $nick $::checkpays::salonado"
 
	}
 
}
 
proc ::checkpays::traitement {nick username ip ipdns vhost codepays asn asname reputation sslco webirc websocket unknow realname account} {
 
	set SESSION [md5 "${username}@${vhost}"]
	set ALLEXCEPTIONS [list {*}$::checkpays::PAYSINTERDIT {*}$::checkpays::PAYSINTERDITNWSI {*}$::checkpays::PAYSINTERDITNW {*}$::checkpays::PAYSIPAPI {*}$::checkpays::PAYSEXCEPTION]

	# Traitement
	if {[lsearch $::checkpays::PAYSINTERDIT $codepays] != -1} {
 
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,4PAYS BLOQUÉ\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		unset ::checkpays::DB($SESSION)
		return
 
	} elseif {([lsearch $::checkpays::PAYSINTERDITNWSI $codepays] != -1) && ($webirc == 0) && ($websocket == 0) && ($reputation < 200)} {
 
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,12PAYS BLOQUÉ - HORS WEB|RÉPUTATION\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		unset ::checkpays::DB($SESSION)
		return
 
	} elseif {([lsearch $::checkpays::PAYSINTERDITNW $codepays] != -1) && ($webirc == 0) && ($websocket == 0)} {
 
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,6PAYS BLOQUÉ - HORS WEB\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		unset ::checkpays::DB($SESSION)
		return
 
	} elseif {($codepays eq "US") || ([string match "*.irccloud.com" $ip])} {
 
		putnow "GLINE $username@$ip $::checkpays::timeBans $::checkpays::motifpaysbl"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,10IRCCloud|US\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		unset ::checkpays::DB($SESSION)
		return
 
	} else {
 
		# Si on entre pas dans une condition blacklisté on envoie à la proc du monitoring
		#::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		#::checkpays::CountIRC $ip $username $codepays $webirc $websocket
 
	}

	# Vérification si le codepays est hors liste interdit/protégé
	if {[lsearch $ALLEXCEPTIONS $codepays]==-1} {
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,14USER SUSPECT\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Réputation: $reputation) (Ssl: $sslco) (Webirc: $webirc) (Websocket: $websocket) (Asn: $asn) (Asname: $asname) - Realname: $realname"
		::checkpays::infoAPI $nick $username $vhost $ip $ipdns $unknow $reputation $realname $webirc $websocket $account
		::checkpays::infoABUSEIPDB $nick $username $vhost $ipdns
	}

	# IP-API

	# Bloquer IPAPI Proxy/Hosting - IPABUSEIPDB
	if {[lsearch $::checkpays::PAYSIPAPI $codepays]!=-1} {
		::checkpays::infoAPI $nick $username $vhost $ip $ipdns $unknow $reputation $realname $webirc $websocket $account
	}

	# Suppression des valeurs en mémoire.
	# https://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tcl/unset.n.html
 
	unset ::checkpays::DB($SESSION)
 
}
 
proc ::checkpays::infoAPI {nick username vhost ip ipdns unknow reputation realname webirc websocket account} {
 
	set SESSION [md5 "${username}@${vhost}"]

	# Encoding pour corriger un problème de charset. Ex: Île-de-France
	set data [encoding convertfrom utf-8 [::toolsAmand::getipdatas $ipdns]]
 
	if {$data == 0} {
		unset ::checkpays::DB($SESSION)
		return
	}
 
    set country [dict get $data country]
    set regionName [dict get $data regionName]
	set region [dict get $data region]
    set city [dict get $data city]
    set codepays [dict get $data countryCode]
    set codepostal [dict get $data zip]
    set isp [dict get $data isp]
    set mobile [dict get $data mobile]
    set proxy [dict get $data proxy]
    set hosting [dict get $data hosting]
	set org [dict get $data org]
	set as [dict get $data as]
	set asname [dict get $data asname]
	set district [dict get $data district]

 
	# Bloquer IPAPI Proxy/Hosting
	if {([lsearch $::checkpays::PAYSIPAPI $codepays]!=-1) && ($proxy eq "true" || $hosting eq "true")} {
		putnow "GLINE *@$ip $::checkpays::timeBans $::checkpays::motifpaysbl \[IP-API\]"
		putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,13IP-API PROXY|HOSTING\003\002 \[\002$codepays\002\] - \002$nick\002 ($username@$ip) (Webirc: $webirc) (Websocket: $websocket) (Région: $regionName) (Ville: $city $codepostal) (Fournisseur: $isp) (Org: $org) (As: $as) (Asname: $asname) (Proxy: $proxy) (Mobile: $mobile) (Hébergeur: $hosting) (Unknow: $unknow) (Réputation: $reputation) - Realname: $realname"
		unset ::checkpays::DB($SESSION)
		return
	}
 
}
 
proc ::checkpays::infoABUSEIPDB {nick username vhost ipdns} {
 
	set SESSION [md5 "${username}@${vhost}"]
	set data [::toolsAmand::abuseipdb $ipdns]
 
	if {$data == 0} {
		unset ::checkpays::DB($SESSION)
		return
	}
 
	set abuseConfidenceScore [dict get $data data abuseConfidenceScore]
	set codepays [dict get $data data countryCode]
	set isTor [dict get $data data isTor]
	set totalReports [dict get $data data totalReports]
 
	putnow "PRIVMSG $::checkpays::backpaysbl :\002\0030,12ABUSEIPDB\003\002 \[$nick!$username@\002$ipdns\002\] \[\002$codepays\002\] - Score: $abuseConfidenceScore \002|\002 isTor: $isTor \002|\002 totalReports: $totalReports"
 
}



J'ai mis des unset de la variable $SESSION dans les conditions ou il y a un return , opter pour une liste sur le stockage des variables en session pour éviter de set chaque variable.
Répondre
#3
Autre petite optimisation proposée:
tcl
# On envoie à la proc de traitement
::checkpays::traitement $SESSION
...
proc ::checkpays::traitement {SESSION} {
   lassign $::checkpays::DB($SESSION) ip ipdns codepays asn asname reputation sslco webirc websocket unknow account
   set ALLEXCEPTIONS [list {*}$::checkpays::PAYSINTERDIT {*}$::checkpays::PAYSINTERDITNWSI {*}$::checkpays::PAYSINTERDITNW {*}$::checkpays::PAYSIPAPI {*}$::checkpays::PAYSEXCEPTION]



Et idem pour ::checkpays::infoAPI
Répondre
#4
je pense que tu voulais plutôt dire $::checkpays:Very HappyB($SESSION) au lieu de $SESSION

Il faut aussi que je trouve une solution pour l'appel de mes deux procs dans la proc traitement:

tcl
	} else {
 
		# Si on entre pas dans une condition blacklisté on envoie à la proc du monitoring
		::checkpays::monitoring $nick $username $ip $vhost $codepays $reputation $sslco $webirc $websocket $realname $asn $asname
		::checkpays::CountIRC $ip $username $codepays $webirc $websocket
 
	}



qui fait des requêtes sql , ça ralenti le script, je sais pas si il y a moyen de gérer ça de manière indépendant.
Répondre
#5
(Il y a 6 heures)Amand a écrit : je pense que tu voulais plutôt dire $::checkpays::DB($SESSION) au lieu de $SESSION
Non.
Ta variable est dans le namespace, pourquoi la transmettre alors que tu peux juste transmettre la valeur de $SESSION pour ne pas avoir à recalculer le md5 et accéder simplement à l'item de ta variable ?
Répondre
#6
quand je fais un putlog de $SESSION avant

tcl
	# On envoie à la proc de traitement
	::checkpays::traitement $nick $username $ip $ipdns $vhost $codepays $asn $asname $reputation $sslco $webirc $websocket $unknow $realname $account



voici le résultat :

SESSION => b70fc77168673cc0c4b938e246d3ecf1

il me retourne le md5 de $username + $vhost
Répondre


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté