;; @module down_up.lsp ;; @description another uTorrent shaper ;; @author Cyril Slobin ;; @location http://slobin.pp.ru/newlisp/down_up.lsp ;; @version $Id: down_up.lsp,v 1.3 2010/11/25 20:55:07 slobin Exp $ ; TODO: http://forum.utorrent.com/viewtopic.php?pid=461130#p461130 ; hacked from ushaper.lsp for SL (import "kernel32" "FreeConsole") (FreeConsole) ; You should customize the following settings. ; Try not to lose your parentheses balance! (setq ip "127.0.0.1") (setq port "49999") (setq user "athens") (setq pass "greece") (setq timeout 500) ; ms (setq down '( (max_dl_rate 125) (max_ul_rate 15) (max_ul_rate_seed 15) (sched_dl_rate 125) (sched_ul_rate 15) )) (setq up '( (max_dl_rate 600) (max_ul_rate 48) (max_ul_rate_seed 72) (sched_dl_rate 400) (sched_ul_rate 48) )) ; The customizable settings end here. Do not edit anything ; below this line! Or do, I don't care... (import "kernel32" "CreateProcessA") (import "kernel32" "WaitForSingleObject") (import "kernel32" "CloseHandle") (define (run-and-wait command-line , si pi ph th) (setq si (pack "ld n64" 68)) (setq pi (pack "n16")) (CreateProcessA 0 command-line 0 0 0 0 0 0 si pi) (map set '(ph th) (unpack "ld ld" pi)) (WaitForSingleObject ph 0xFFFFFFFF) (CloseHandle ph) (CloseHandle th)) (setq url-base (format "http://%s:%s/gui/" ip port)) (setq ticket (base64-enc (append user ":" pass))) (setq auth (format "Authorization: Basic %s\r\n" ticket)) (setq token-url (append url-base "token.html")) (setq token-regex {\]*\>([^<]*)\<\/div\>}) (define (pair arg) (format "&s=%s&v=%s" (string (arg 0)) (string (arg 1)))) (define (call-webapi arg , head tail) (setq $1 "oops") ; should fail (regex token-regex (get-url token-url timeout auth)) (setq head (format "?token=%s&action=setsetting" $1)) (setq tail (join (map pair arg))) (get-url (append url-base head tail) timeout auth)) ; Main (call-webapi down) (run-and-wait (main-args -1)) (call-webapi up) (exit)