
HMA VPN Server Harvester
By:
Sly on
Apr 22nd, 2012 | syntax:
CoffeeScript | size: 1.15 KB | hits: 70 | expires: Never
log = console.log
http = require 'http'
parseUrl= require('url').parse
fs = require 'fs'
urls =
server_list: 'http://vpn.hidemyass.com/vpnconfig/countries.php'
server_config: 'http://vpn.hidemyass.com/vpnconfig/client_config.php?win=1&loc='
get = (url, callback) ->
# No callback? Waste of time. Just exit.
if !callback then return
http.get parseUrl(url), (res) ->
data = ''
res.setEncoding 'utf-8'
res.on 'data', (chunk) ->
data += chunk
res.on 'end', ->
callback data
try
fs.mkdirSync './servers'
log 'Created directory: ' + __dirname + '/servers'
catch error
get urls.server_list, (data) ->
lines = data.trim().split '\n'
for line in lines
do ->
if line.length > 0
line = line.trim()
log "Got server: #{line}"
((line) ->
server = encodeURI line
get "#{urls.server_config}#{server}", (data) ->
try
file = __dirname + "/servers/#{line}.conf"
fs.writeFileSync file, data
log "Wrote configuration #{file}"
catch error
throw error
)(line)