github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/cmd/geph-client/chinalist/generate-list.rkt (about) 1 #lang racket 2 (require net/url) 3 4 (define seen (mutable-set)) 5 6 (define (generate-list (name "geolocation-cn")) 7 (define url (string->url 8 (format "https://raw.githubusercontent.com/v2ray/domain-list-community/master/data/~a" name))) 9 (for ([line (in-lines (get-pure-port url))]) 10 (match (string-trim line) 11 [(or "" (regexp #rx"^#")) (void)] 12 [(regexp #rx"^include:") 13 (generate-list (car (string-split (substring line 8))))] 14 [(regexp #rx":") (void)] 15 [x 16 (define element (car (string-split x))) 17 (unless (set-member? seen element) 18 (set-add! seen element) 19 (printf "~v : true,\n" (car (string-split x))))]))) 20 21 (displayln "package chinalist") 22 (displayln "var domainList = map[string]bool{") 23 (generate-list) 24 (displayln "}")