fork download
  1. (use rfc.http)
  2. (use rfc.base64)
  3. (use gauche.process)
  4.  
  5. (define chosenCountry "US")
  6.  
  7. (define URL "http://w...content-available-to-author-only...e.net/api/iphone/")
  8.  
  9. (define (url-split url)
  10. (if-let1 m (#/https?:\/\/([^\/]+)(\/.+)/ url)
  11. (values (m 1) (m 2))))
  12.  
  13. (define (prompt s)
  14. (display s)
  15. (flush (current-output-port))
  16. (read-line))
  17.  
  18. (define (main args)
  19. (when (< 1 (length args))
  20. (set! chosenCountry (list-ref 1)))
  21. (print "[autovpn] getting server list")
  22. (let*-values (((domain path)
  23. (url-split URL))
  24. ((status header body)
  25. (http-get domain path)))
  26. (print "[autovpn] parsing response")
  27. (print "[autovpn] looking for " chosenCountry)
  28. (call-with-input-string body
  29. (lambda(p)
  30. (read-line p)
  31. (generator-map
  32. (lambda(line)
  33. (and-let* ((splits (string-split line #\,))
  34. ((<= 15 (length splits)))
  35. (country (list-ref splits 6))
  36. (conf (base64-decode-string (list-ref splits 14))))
  37. (when (string=? country chosenCountry)
  38. (with-output-to-file "/tmp/openvpnconf" (cut print conf))
  39. (let1 process
  40. (run-process '("sudo" "openvpn" "/tmp/openvpnconf"))
  41. (with-signal-handlers
  42. ((SIGTERM (process-send-signal process SIGTERM)))
  43. (process-wait process)))
  44. (let1 i (prompt "[autovpn] try another VPN? (y/n)")
  45. (when (and (string? i)
  46. (< 0 (string-length i))
  47. (char=? (char-downcase (string-ref i 0)) #\n))
  48. (exit 0))))))
  49. (cut read-line p)
  50. )))))
  51.  
Runtime error #stdin #stdout #stderr 0s 18088KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: (import) during expansion of (import ...) - cannot import from undefined module: rfc.http

	Call history:

	<syntax>	  (use rfc.http)
	<syntax>	  (##core#require-extension (rfc.http) #t)
	<syntax>	  (##core#begin (##core#begin (##sys#require (quote rfc.http)) (import rfc.http)) (##core#undefined))
	<syntax>	  (##core#begin (##sys#require (quote rfc.http)) (import rfc.http))
	<syntax>	  (##sys#require (quote rfc.http))
	<syntax>	  (quote rfc.http)
	<syntax>	  (##core#quote rfc.http)
	<syntax>	  (import rfc.http)	<--