📄 macro.java
字号:
// addresses will be filled in automatically staticMacros.addElement(m); m = new Macro(STATIC_FIREWALLS_IDENTPORT); m.macroName = "FW-IDENTPORT"; m.macroType = MACRO_ADDRESSLIST; m.macroSpecial = MACRO_FIREWALLS; m.port = 113; m.prend = 113; // addresses will be filled in automatically staticMacros.addElement(m); m = new Macro(STATIC_FIREWALLS_TRACEROUTEPORTS); m.macroName = "FW-IDENTPORT"; m.macroType = MACRO_ADDRESSLIST; m.macroSpecial = MACRO_FIREWALLS; m.port = 33434; m.prend = 33523; // addresses will be filled in automatically staticMacros.addElement(m); m = new Macro(STATIC_CONFIG_CLIENTS); m.macroName = "CONFCLIENTS"; m.macroType = MACRO_ADDRESSLIST; m.macroSpecial = MACRO_CONFCLIENTS; // addresses will be filled in automatically staticMacros.addElement(m); m = new Macro(STATIC_INSIDE); m.macroName = "INSIDE"; m.macroType = MACRO_INSIDE; staticMacros.addElement(m); m = new Macro(STATIC_OUTSIDE); m.macroName = "OUTSIDE"; m.macroType = MACRO_OUTSIDE; staticMacros.addElement(m); m = new Macro(STATIC_LOCALHOST); m.macroName = "LOCALHOST"; m.macroType = MACRO_ADDRESSLIST; m.addresses.addAddress("127.0.0.1"); staticMacros.addElement(m); m = new Macro(STATIC_SMTPPORT); m.macroName = "SMTP-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 25; m.prend = 25; staticMacros.addElement(m); m = new Macro(STATIC_IDENTPORT); m.macroName = "IDENT-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 113; m.prend = 113; staticMacros.addElement(m); m = new Macro(STATIC_RUSERPORT); m.macroName = "RUSER-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 111; m.prend = 111; staticMacros.addElement(m); m = new Macro(STATIC_DNSPORT); m.macroName = "DNS-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 53; m.prend = 53; staticMacros.addElement(m); m = new Macro(STATIC_FTPPORT); m.macroName = "FTP-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 21; m.prend = 21; staticMacros.addElement(m); m = new Macro(STATIC_TELNETPORT); m.macroName = "TELNET-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 23; m.prend = 23; staticMacros.addElement(m); m = new Macro(STATIC_SSHPORT); m.macroName = "SSH-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 22; m.prend = 22; staticMacros.addElement(m); m = new Macro(STATIC_HTTPPORTS); m.macroName = "HTTP-PORTS"; m.macroType = MACRO_PORTS_ONLY; m.port = 80; m.prend = 81; staticMacros.addElement(m); m = new Macro(STATIC_HTTPSPORTS); m.macroName = "HTTPS-PORTS"; m.macroType = MACRO_PORTS_ONLY; m.port = 443; m.prend = 444; staticMacros.addElement(m); m = new Macro(STATIC_TRACEROUTEPORTS); m.macroName = "TRCRTE-PORTS"; m.macroType = MACRO_PORTS_ONLY; m.port = 33434; m.prend = 33523; staticMacros.addElement(m); m = new Macro(STATIC_INSIDE_IDENTPORT); m.macroName = "INS_IDENT"; m.macroType = MACRO_INSIDE; m.port = 113; m.prend = 113; staticMacros.addElement(m); m = new Macro(STATIC_INSIDE_TRACEROUTEPORTS); m.macroName = "INS_TRTE"; m.macroType = MACRO_INSIDE; m.port = 33434; m.prend = 33523; staticMacros.addElement(m); m = new Macro(STATIC_OWNADDRESSES); m.macroName = "OWNADDR"; m.macroType = MACRO_OWNADDR; staticMacros.addElement(m); m = new Macro(STATIC_OWNADDRESSES_FWPORT); m.macroName = "OWNFIREWALL"; m.macroType = MACRO_OWNADDR; m.port = Communicator.serverPort; m.prend = Communicator.serverPort; staticMacros.addElement(m); m = new Macro(STATIC_FINGERPORT); m.macroName = "FINGER-PORT"; m.macroType = MACRO_PORTS_ONLY; m.port = 79; m.prend = 79; staticMacros.addElement(m); }} // Macro// Dialog box for editing macrosclass MacroDialog extends Dialog implements ActionListener { /** * @param co calling object, refresh() will be called after "OK" * @param p parent window * @param n macro to be edited * @param md manage domain holding dynamic macros * @param nw if true, macro will be removed from vector * in md when "Cancel" has been selected */ public MacroDialog(Refreshable co, Frame p, Macro m, ManageDomain md, boolean nw) { super(p, "Address Macros", true); callingObject = co; parent = p; macro = m; mgDomain = md; newMacro = nw; GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(3,3,3,3); setLayout(gbl); mName = new TextField(m.macroName, 10); Utils.add_component(this, new Label("Name:"), gbl, gbc, 0, 0, 1, 1, 0, 0); Utils.add_component(this, mName, gbl, gbc, 1, 0, 1, 1, 0, 0); CheckboxGroup cg = new CheckboxGroup(); insideBox = new Checkbox("Inside", cg, m.macroType == Macro.MACRO_INSIDE); Utils.add_component(this, insideBox, gbl, gbc, 0, 1, 2, 1, 0, 0); outsideBox = new Checkbox("Outside", cg, m.macroType == Macro.MACRO_OUTSIDE); Utils.add_component(this, outsideBox, gbl, gbc, 0, 2, 2, 1, 0, 0); addressBox = new Checkbox("Addresses", cg, m.macroType == Macro.MACRO_ADDRESSLIST); Utils.add_component(this, addressBox, gbl, gbc, 0, 3, 2, 1, 0, 0); portsonlyBox = new Checkbox("Ports only", cg, m.macroType == Macro.MACRO_PORTS_ONLY); Utils.add_component(this, portsonlyBox, gbl, gbc, 0, 4, 2, 1, 0, 0); Panel ap = m.addresses.editPanel(); Utils.add_component(this, ap, gbl, gbc, 0, 5, 4, 8, 100, 100); Utils.add_component(this, new Label("Port"), gbl, gbc, 0, 13, 1, 1, 0, 0); portText = new TextField(6); // allow service names !!! Utils.add_component(this, portText, gbl, gbc, 1, 13, 1, 1, 50, 0); prendText = new TextField(6); if (m.port != Macro.MACRO_FIRSTPORT || m.prend != Macro.MACRO_LASTPORT) { portText.setText(Integer.toString(m.port)); if (m.prend != m.port) prendText.setText(Integer.toString(m.prend)); } Utils.add_component(this, new Label(".."), gbl, gbc, 2, 13, 1, 1, 0, 0); Utils.add_component(this, prendText, gbl, gbc, 3, 13, 1, 1, 50, 0); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; Panel pa = new Panel(); OKbutton = new Button("OK"); OKbutton.addActionListener(this); pa.add(OKbutton); // Cancelbutton = new Button("Cancel"); // !!! pa.add(Cancelbutton); Utils.add_component(this, pa, gbl, gbc, 0, 14, 4, 1, 0, 0); pack(); addWindowListener(new MDAdapter()); }class MDAdapter extends WindowAdapter { public void windowClosing(WindowEvent we) { if (isEnabled()) dispose(); }} // class MDAdapter public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); // Process OKbutton if (source == OKbutton) { // don't save changes in static macros if (macro.macroNumber <= Rule.SF_FIRSTMACRO && macro.macroNumber > Macro.firstDynamic) { dispose(); return; } String str = mName.getText().trim().toUpperCase(); Enumeration en = mgDomain.Macros.elements(); Macro m; while (en.hasMoreElements()) { m = (Macro)en.nextElement(); if (m != macro && m.macroName.equals(str)) { UserDialog.ErrorBox("Macro "+str+" already exists!"); return; } } macro.macroName = str; if (insideBox.getState()) macro.macroType = Macro.MACRO_INSIDE; if (outsideBox.getState()) macro.macroType = Macro.MACRO_OUTSIDE; if (portsonlyBox.getState()) macro.macroType = Macro.MACRO_PORTS_ONLY; if (!addressBox.getState()) { macro.addresses = new AddrList(); } str = portText.getText().trim(); if (str.length() > 0) { // !!! allow service names try { macro.port = Integer.parseInt(str); if (macro.port < Macro.MACRO_FIRSTPORT || macro.port > Macro.MACRO_LASTPORT) macro.port = Macro.MACRO_FIRSTPORT; } catch (NumberFormatException e) { macro.port = Macro.MACRO_FIRSTPORT; } } else macro.port = Macro.MACRO_FIRSTPORT; str = prendText.getText().trim(); if (str.length() > 0) { try { macro.prend = Integer.parseInt(str); if (macro.prend < Macro.MACRO_FIRSTPORT || macro.prend > Macro.MACRO_LASTPORT || macro.prend < macro.port) macro.prend = macro.port == Macro.MACRO_FIRSTPORT ? Macro.MACRO_LASTPORT : macro.port; } catch (NumberFormatException e) { macro.prend = macro.port == Macro.MACRO_FIRSTPORT ? Macro.MACRO_LASTPORT : macro.port; } } else macro.prend = macro.port == Macro.MACRO_FIRSTPORT ? Macro.MACRO_LASTPORT : macro.port; if (callingObject != null) callingObject.refresh(); dispose(); return; } // Process Cancelbutton else if (source == Cancelbutton) { if (newMacro) mgDomain.Macros.removeElement(macro); dispose(); return; } } // actionPerformed private Refreshable callingObject; private Frame parent; private Macro macro; private ManageDomain mgDomain; private boolean newMacro; private Button OKbutton; private Button Cancelbutton; private TextField mName; private Checkbox insideBox; private Checkbox outsideBox; private Checkbox addressBox; private Checkbox portsonlyBox; private TextField portText; private TextField prendText;} // MacroDialog
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -