Rev 1196 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1194 | dev | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Data; |
||
5 | using System.Drawing; |
||
6 | using System.Net; |
||
7 | using System.Text; |
||
8 | using System.Windows.Forms; |
||
9 | |||
10 | namespace TCPproxy |
||
11 | { |
||
12 | public partial class ListenForm : Form |
||
13 | { |
||
14 | private int listenPort; |
||
15 | private string resendHost; |
||
16 | private IPAddress resendIp; |
||
17 | private int resendPort; |
||
18 | |||
19 | public ListenForm() |
||
20 | { |
||
21 | InitializeComponent(); |
||
22 | } |
||
23 | |||
24 | public bool Execute(Form owner, |
||
25 | ref int listenPort, ref string resendHost, out IPAddress resendIp, ref int resendPort) |
||
26 | { |
||
27 | listenPortBox.Text = (listenPort == 0) ? "" : listenPort.ToString(); |
||
28 | resendHostBox.Text = resendHost; |
||
29 | resendPortBox.Text = (resendPort == 0) ? "" : resendPort.ToString(); |
||
30 | |||
31 | if(this.ShowDialog(owner) != DialogResult.OK) { |
||
32 | resendIp = null; |
||
33 | return false; |
||
34 | } |
||
35 | |||
36 | listenPort = this.listenPort; |
||
37 | resendHost = this.resendHost; |
||
38 | resendIp = this.resendIp; |
||
39 | resendPort = this.resendPort; |
||
40 | |||
41 | return true; |
||
42 | } |
||
43 | |||
44 | private void startButton_Click(object sender, EventArgs e) |
||
45 | { |
||
46 | // parse listen port |
||
47 | try |
||
48 | { |
||
49 | listenPort = int.Parse(listenPortBox.Text); |
||
50 | } |
||
51 | catch(FormatException) |
||
52 | { |
||
53 | MessageBox.Show("Listen port must be an integer number"); |
||
54 | return; |
||
55 | } |
||
56 | |||
57 | // get resend host |
||
58 | try |
||
59 | { |
||
60 | resendIp = HostUtils.ResendHostToIp(resendHostBox.Text); |
||
61 | } |
||
62 | catch(Exception ex) |
||
63 | { |
||
64 | MessageBox.Show(ex.Message); |
||
65 | return; |
||
66 | } |
||
67 | resendHost = resendHostBox.Text; |
||
68 | |||
69 | // parse resend port |
||
70 | try |
||
71 | { |
||
72 | resendPort = int.Parse(resendPortBox.Text); |
||
73 | } |
||
74 | catch(FormatException) |
||
75 | { |
||
76 | MessageBox.Show("Resend port must be an integer number"); |
||
77 | return; |
||
78 | } |
||
79 | |||
80 | this.DialogResult = DialogResult.OK; |
||
81 | this.Close(); |
||
82 | } |
||
83 | } |
||
84 | } |