1 |
Douglas Thrift |
77 |
// Host Update Sharp |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
using System; |
8 |
|
|
using System.IO; |
9 |
|
|
using System.Net; |
10 |
Douglas Thrift |
82 |
using System.Text; |
11 |
Douglas Thrift |
77 |
|
12 |
Douglas Thrift |
78 |
public class HostUpdateSharp |
13 |
Douglas Thrift |
77 |
{ |
14 |
Douglas Thrift |
78 |
public static void Main(string[] args) |
15 |
Douglas Thrift |
77 |
{ |
16 |
Douglas Thrift |
85 |
#if _uname_ = "FreeBSD 4.9-STABLE i386" |
17 |
|
|
String os = "FreeBSD 4.9-STABLE i386"; |
18 |
Douglas Thrift |
83 |
#else |
19 |
|
|
OperatingSystem os = Environment.OSVersion; |
20 |
|
|
#endif |
21 |
|
|
StringBuilder host = new StringBuilder("host=" + Dns.GetHostName()); |
22 |
Douglas Thrift |
78 |
string url = "http://topsecret.douglasthrift.net/auth/hostupdate.cgi"; |
23 |
|
|
|
24 |
Douglas Thrift |
82 |
if (host.ToString().IndexOf('.') < 0) |
25 |
|
|
{ |
26 |
|
|
host.Append(".local.douglasthrift.net"); |
27 |
|
|
} |
28 |
|
|
|
29 |
Douglas Thrift |
83 |
Console.WriteLine(host); |
30 |
Douglas Thrift |
84 |
Console.WriteLine(os); |
31 |
Douglas Thrift |
83 |
|
32 |
Douglas Thrift |
82 |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
33 |
|
|
|
34 |
|
|
request.Accept = "text/plain"; |
35 |
Douglas Thrift |
83 |
request.ContentLength = host.Length; |
36 |
Douglas Thrift |
82 |
request.ContentType = "application/x-www-form-urlencoded"; |
37 |
|
|
request.Credentials = new NetworkCredential("HostUpdate", "frell2003"); |
38 |
Douglas Thrift |
83 |
request.KeepAlive = false; |
39 |
Douglas Thrift |
82 |
request.Method = "POST"; |
40 |
Douglas Thrift |
83 |
request.PreAuthenticate = true; |
41 |
|
|
request.UserAgent = "Host Update Sharp/1.0 (" + os + ")"; |
42 |
Douglas Thrift |
77 |
} |
43 |
|
|
} |