Skip to content

Instantly share code, notes, and snippets.

@fenrir-naru
Last active May 8, 2019 15:17
Show Gist options
  • Save fenrir-naru/63f71c5f9b1b7cb1fce4 to your computer and use it in GitHub Desktop.
Save fenrir-naru/63f71c5f9b1b7cb1fce4 to your computer and use it in GitHub Desktop.
Address verifier for emailrelay
@C:\path\to\bin\ruby.exe -x "%~f0" %*
@exit /b %ERRORLEVEL%
#!/usr/bin/ruby
# coding: utf-8
address = ARGV[0]
def runner(&b)
if RUBY_PLATFORM =~ /mingw/ then
t = Thread::new{b.call}
def t.wait; self.join; end
t
else
pid = fork{b.call}
def pid.wait; Process.wait(self); end
pid
end
end
res = 0
if address !~ /\@example\.com$/ then
read_p2c, write_p2c = IO::pipe
read_c2p, write_c2p = IO::pipe
job = runner{
#read_c2p.close
require 'win32ole'
wsh = WIN32OLE.new('WScript.Shell')
Marshal::dump(wsh.popup("アドレスを確認、送信する?\r\n" + Marshal::load(read_p2c.read), 0, '', 1), write_c2p)
write_c2p.close
wsh.ole_free
}
#read_p2c.close
Marshal::dump(address, write_p2c)
write_p2c.close
job.wait
res = Marshal::load(read_c2p.read)
end
case res
when 2
print "invalid address.\r\n"
exit(2)
end
print "\r\n"
print "#{address}\r\n"
exit 1
__END__
start "emailrelay" "C:\Program Files (x86)\emailrelay\emailrelay.exe" --close-stderr --as-proxy smtp.forward.com:25 --immediate --log --pid-file "C:\Program Files (x86)\emailrelay\emailrelay.pid" --port 10025 --remote-clients --spool-dir "C:\Program Files (x86)\emailrelay\spool" --address-verifier "C:\Program Files (x86)\emailrelay\check_address.bat"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment