16 |
|
{ |
17 |
|
public static void Main(string[] args) |
18 |
|
{ |
19 |
+ |
foreach (string arg in args) |
20 |
+ |
{ |
21 |
+ |
switch (arg) |
22 |
+ |
{ |
23 |
+ |
case "-D": |
24 |
+ |
debug = true; |
25 |
+ |
break; |
26 |
+ |
} |
27 |
+ |
} |
28 |
+ |
|
29 |
|
try |
30 |
|
{ |
31 |
|
new HostUpdateSharp(); |
42 |
|
host.Append(".local.douglasthrift.net"); |
43 |
|
} |
44 |
|
|
45 |
+ |
WebHeaderCollection headers = new WebHeaderCollection(); |
46 |
+ |
|
47 |
+ |
headers.Add("Authorization", "Basic " + Convert.ToBase64String((new |
48 |
+ |
ASCIIEncoding()).GetBytes("HostUpdate:frell2003"))); |
49 |
+ |
|
50 |
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
51 |
|
|
52 |
|
request.Accept = "text/plain"; |
53 |
|
request.ContentLength = host.Length; |
54 |
|
request.ContentType = "application/x-www-form-urlencoded"; |
55 |
< |
request.Credentials = new NetworkCredential("HostUpdate", "frell2003"); |
55 |
> |
request.Headers = headers; |
56 |
|
request.KeepAlive = false; |
57 |
|
request.Method = "POST"; |
43 |
– |
request.PreAuthenticate = true; |
58 |
|
request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')'; |
59 |
|
|
60 |
|
StreamWriter post = new StreamWriter(request.GetRequestStream(), |
68 |
|
StreamReader content = new StreamReader(response.GetResponseStream(), |
69 |
|
Encoding.ASCII); |
70 |
|
|
71 |
< |
Console.Write(content.ReadToEnd()); |
71 |
> |
#if _FreeBSD_ |
72 |
> |
if (debug) Console.Write(content.ReadToEnd()); |
73 |
> |
#else |
74 |
> |
if (debug) MessageBox.Show(content.ReadToEnd(), "Host Update Sharp", |
75 |
> |
MessageBoxButtons.OK, MessageBoxIcon.Information); |
76 |
> |
#endif |
77 |
> |
|
78 |
|
content.Close(); |
79 |
|
} |
80 |
+ |
private static bool debug = false; |
81 |
|
#if _FreeBSD_ |
82 |
|
private string platform() { return "FreeBSD 4.9-STABLE i386"; } |
83 |
|
#else |