📄 host.javatemp
字号:
/** * @return string describing the host */ public String toString() { return "Host: "+objectInfo(); } private static java.awt.image.ImageProducer bSource = null; // host properties protected AddrList HostAddresses = new AddrList(); protected AddrList internalAddresses = null; // automatically calculated protected boolean isFirewall = false; // is this host a firewall? protected boolean transparent = true; // route traffic from outside to outside protected boolean isServer = false; // is this host a server (e.g.WWW) ? protected boolean publicServer = true; // is this server a public server, // i.e. access from the internet allowed? protected boolean hostTemplates[]; // variables for sfc show data protected transient boolean isLoaded = false; protected transient byte addr[][]; protected transient byte mask[][]; protected transient short port[]; protected transient short prend[]; protected transient Vector rules; protected transient String varnames[]; protected transient int varvalues[][]; protected transient byte varaddr[][][]; protected transient Date vartimeout[][]; protected transient Vector tcpconns; protected transient Date actDate; // server time and date when reading tcp connections private transient FirewallAction actionFrame = null;} // Host// Dialog to enter the host settingsclass HostProperties extends Dialog implements ActionListener, ItemListener, TextListener { public HostProperties(Frame parent, String title, Host hst) { super(parent, title, true); host = hst; GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5,5,5,5); setLayout(gbl); // Name panel Utils.add_component(this, new ImageLabel(host.icon), gbl, gbc, 0, 0, 1, 1, 0, 0); Utils.add_component(this, new Label("Identifier: "), gbl, gbc, 1, 0, 1, 1, 0, 0); IDtext = new TextField(host.objectID); IDtext.addTextListener(this); Utils.add_component(this, IDtext, gbl, gbc, 2, 0, 3, 1, 100, 0); // Address panel Panel ap = host.HostAddresses.editPanel(); Utils.add_component(this, ap, gbl, gbc, 0, 1, 3, 8, 80, 100); // Host type panel FirewallBox = new Checkbox("Firewall", host.isFirewall); FirewallBox.addItemListener(this); FirewallMore = new Button("More..."); FirewallMore.addActionListener(this); Utils.add_component(this, FirewallBox, gbl, gbc, 3, 2, 1, 1, 0, 0); Utils.add_component(this, FirewallMore, gbl, gbc, 4, 2, 1, 1, 0, 0); ServerBox = new Checkbox("Server", host.isServer); ServerBox.addItemListener(this); ServerMore = new Button("More..."); ServerMore.addActionListener(this); Utils.add_component(this, ServerBox, gbl, gbc, 3, 3, 1, 1, 0, 0); Utils.add_component(this, ServerMore, gbl, gbc, 4, 3, 1, 1, 0, 0); // Buttons OKbutton = new Button("OK"); OKbutton.addActionListener(this); gbc.fill = GridBagConstraints.NONE; Utils.add_component(this, OKbutton, gbl, gbc, 0, 9, 5, 1, 0, 0); // Window size Graphics g = parent.getGraphics(); FontMetrics fm = g.getFontMetrics(); setSize(fm.stringWidth("255.255.255.255/255.255.255.255 ") * 2, fm.getHeight() * 20 ); g.dispose(); addWindowListener(new HPAdapter()); } // Handle Windowclosingclass HPAdapter extends WindowAdapter { public void WindowClosing(WindowEvent we) { if (isEnabled()) dispose(); return; }} // HPAdapter // Process Buttons public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); // Process OKbutton if (source==OKbutton) { host.objectID = IDtext.getText().trim(); dispose(); return; } // Process FirewallMore else if (source==FirewallMore) { if (host.isFirewall) { AutoconfSettings as = new AutoconfSettings( Utils.getParentFrame(this), "Firewall Settings", host, Templates.startFirewall, Templates.numberFirewall); as.setVisible(true); } return; } // Process ServerMore else if (source==ServerMore) { if (host.isServer) { AutoconfSettings as = new AutoconfSettings( Utils.getParentFrame(this), "Server Settings", host, Templates.startServer, Templates.numberServer); as.setVisible(true); } return; } } // actionPerformed // Process Checkboxes public void itemStateChanged(ItemEvent ie) { Object source = ie.getSource(); // Process FirewallBox if (source==FirewallBox) { host.isFirewall = FirewallBox.getState(); return; } // Process ServerBox else if (source==ServerBox) { host.isServer = ServerBox.getState(); return; } } // itemStateChanged // Process TextFields public void textValueChanged(TextEvent te) { Object source = te.getSource(); // Process IDtext if (source==IDtext) { host.objectID = (((TextComponent)source).getText().trim()); setTitle("Host "+host.objectID); return; } } // textValueChanged private Host host; private Button OKbutton; private TextField IDtext; private Checkbox FirewallBox; private Checkbox ServerBox; private Button FirewallMore; private Button ServerMore;} // HostProperties// Dialog to enter the firewall and server access profilesclass AutoconfSettings extends Dialog implements ActionListener, ItemListener { public AutoconfSettings(Frame p, String title, Host hst, int st, int no) { super(p, title, true); start = st; number = no; host = hst; GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5,5,5,5); setLayout(gbl); // Checkboxes gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHWEST; if (start == Templates.startServer) { // server dialog publicServerBox = new Checkbox("Public access to this server", host.publicServer); publicServerBox.addItemListener(this); Utils.add_component(this, publicServerBox, gbl, gbc, 0, 0, 4, 1, 0, 0); } if (start == Templates.startFirewall) { // firewall dialog transparentBox = new Checkbox("Allow packets from outside to outside", host.transparent); transparentBox.addItemListener(this); Utils.add_component(this, transparentBox, gbl, gbc, 0, 0, 4, 1, 0, 0); } CheckboxArray = new Checkbox[number]; int half = (int)Math.floor(((double)number / 2.0) + 0.5); for (int i=start; i < start + number; i++) { CheckboxArray[i-start] = new Checkbox(Templates.prompt[i], host.hostTemplates[i-Templates.startServer]); CheckboxArray[i-start].addItemListener(this); if (i-start < half) Utils.add_component(this, CheckboxArray[i-start], gbl, gbc, 0, i-start+1, 2, 1, 0, 0); else Utils.add_component(this, CheckboxArray[i-start], gbl, gbc, 2, i-start-half+1, 2, 1, 0, 0); } // Buttons OKbutton = new Button("OK"); OKbutton.addActionListener(this); Utils.add_component(this, OKbutton, gbl, gbc, 0, half+1, 4, 1, 0, 0); // Window size pack(); addWindowListener(new ASAdapter()); } // Handle Windowclosingclass ASAdapter extends WindowAdapter { public void WindowClosing(WindowEvent we) { if (isEnabled()) dispose(); return; }} // class ASAdapter // Process Buttons public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); if (source==OKbutton) { dispose(); return; } } // actionPerformed // Process Checkboxes public void itemStateChanged(ItemEvent ie) { Object source = ie.getSource(); if (source == publicServerBox) { host.publicServer = publicServerBox.getState(); return; } else if (source == transparentBox) { host.transparent = transparentBox.getState(); return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -