Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Jan 18, 2023
1 parent 9ce5d14 commit 8b1902e
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 131 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,5 @@ Others:

更新内容:
- [important] [improve] CPU占用较高需要进行优化 #128
- [improve] 不常用的配置应该都移到高级配置中 #132
- [improve] 避免直接使用其他项目的图标 #130
48 changes: 48 additions & 0 deletions src/main/java/com/chaitin/xray/form/AdvanceConfigForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,54 @@
</grid>
</children>
</grid>
<grid id="5af19" binding="proxyConfigPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
</properties>
<border type="none" title="代理配置"/>
<children>
<grid id="a10d7" binding="proxyPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
</properties>
<border type="none"/>
<children>
<component id="851c4" class="javax.swing.JButton" binding="proxyConfigButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="确认"/>
</properties>
</component>
<component id="d8618" class="javax.swing.JLabel" binding="proxyLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="输入HTTP代理URL"/>
</properties>
</component>
<component id="cfc86" class="javax.swing.JTextField" binding="proxyText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</form>
68 changes: 68 additions & 0 deletions src/main/java/com/chaitin/xray/form/AdvanceConfigForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public class AdvanceConfigForm {
private JLabel useFullModeLabel;
private JButton xstreamRefreshButton;
private JButton xstreamSaveButton;
private JPanel proxyConfigPanel;
private JPanel proxyPanel;
private JButton proxyConfigButton;
private JLabel proxyLabel;
private JTextField proxyText;

private final List<JCheckBox> baselineCheckBoxList = new ArrayList<>();
private final List<JCheckBox> sqlCheckBoxList = new ArrayList<>();
Expand All @@ -123,7 +128,42 @@ public class AdvanceConfigForm {
private static boolean sqlAll = false;
private static boolean xssAll = false;

@SuppressWarnings("all")
public void refreshHttpProxy() {
String data = null;
for (Map.Entry<String, Object> entry : MainForm.configObj.entrySet()) {
if (entry.getKey().equals("http")) {
Map<String, Object> httpModule = (Map<String, Object>) entry.getValue();
data = (String) httpModule.get("proxy");
}
}
if (data != null) {
proxyText.setText(data);
}
}

@SuppressWarnings("all")
public void initHttpProxy() {
refreshHttpProxy();
proxyConfigButton.addActionListener(e -> {
String httpProxy = proxyText.getText();
for (Map.Entry<String, Object> entry : MainForm.configObj.entrySet()) {
if (entry.getKey().equals("http")) {
Map<String, Object> httpModule = (Map<String, Object>) entry.getValue();
httpModule.put("proxy", httpProxy);
}
}
MainForm.instance.refreshConfig();
if (MainForm.LANG == MainForm.CHINESE) {
JOptionPane.showMessageDialog(this.advanceConfigPanel, "设置代理成功");
} else {
JOptionPane.showMessageDialog(this.advanceConfigPanel, "Success");
}
});
}

private void init() {
initHttpProxy();
baselineCheckBoxList.add(detectCorsHeaderConfigCheckBox);
baselineCheckBoxList.add(detectServerErrorPageCheckBox);
baselineCheckBoxList.add(detectPhpinfoCheckBox);
Expand All @@ -149,6 +189,7 @@ private void init() {
}

private void refreshAll() {
refreshHttpProxy();
refreshBaseline();
refreshThinkphp();
refreshSql();
Expand Down Expand Up @@ -740,6 +781,11 @@ private void initLang() {
useFullModeLabel.setText("是否开启完全扫描模式");
xstreamRefreshButton.setText("刷新配置");
xstreamSaveButton.setText("确认配置");
proxyConfigPanel.setBorder(BorderFactory.createTitledBorder(null,
"代理配置", TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));
proxyLabel.setText("输入HTTP代理URL");
proxyConfigButton.setText("确认");
} else {
configCenterPanel.setBorder(BorderFactory.createTitledBorder(null,
"Config Center", TitledBorder.DEFAULT_JUSTIFICATION,
Expand Down Expand Up @@ -804,6 +850,11 @@ private void initLang() {
useFullModeLabel.setText("use full mode");
xstreamRefreshButton.setText("Refresh");
xstreamSaveButton.setText("Save");
proxyConfigPanel.setBorder(BorderFactory.createTitledBorder(null,
"Proxy Config", TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));
proxyLabel.setText("Input HTTP Proxy");
proxyConfigButton.setText("Confirm");
}
}

Expand Down Expand Up @@ -1179,6 +1230,23 @@ public AdvanceConfigForm() {
xstreamSaveButton = new JButton();
xstreamSaveButton.setText("确认配置");
xstreamPanel.add(xstreamSaveButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
proxyConfigPanel = new JPanel();
proxyConfigPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
proxyConfigPanel.setBackground(new Color(-725535));
advanceConfigPanel.add(proxyConfigPanel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
proxyConfigPanel.setBorder(BorderFactory.createTitledBorder(null, "代理配置", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
proxyPanel = new JPanel();
proxyPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
proxyPanel.setBackground(new Color(-725535));
proxyConfigPanel.add(proxyPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
proxyConfigButton = new JButton();
proxyConfigButton.setText("确认");
proxyPanel.add(proxyConfigButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
proxyLabel = new JLabel();
proxyLabel.setText("输入HTTP代理URL");
proxyPanel.add(proxyLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
proxyText = new JTextField();
proxyPanel.add(proxyText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}

/**
Expand Down
56 changes: 4 additions & 52 deletions src/main/java/com/chaitin/xray/form/MainForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
</component>
</children>
</grid>
<grid id="c3121" binding="rightConfigPanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c3121" binding="rightConfigPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -440,58 +440,10 @@
</properties>
<border type="none"/>
<children>
<grid id="93c21" binding="proxyConfigPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
</properties>
<border type="none" title="代理配置"/>
<children>
<grid id="9c5a0" binding="proxyPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
</properties>
<border type="none"/>
<children>
<component id="f23e7" class="javax.swing.JButton" binding="proxyConfigButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="确认"/>
</properties>
</component>
<component id="53891" class="javax.swing.JLabel" binding="proxyLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="输入HTTP代理URL"/>
</properties>
</component>
<component id="9fade" class="javax.swing.JTextField" binding="proxyText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3d33" binding="reverseConfigPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
Expand Down Expand Up @@ -571,7 +523,7 @@
<grid id="72ed5" binding="startScanPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
Expand Down Expand Up @@ -694,7 +646,7 @@
<grid id="a03a5" binding="otherPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-725535"/>
Expand Down
Loading

0 comments on commit 8b1902e

Please sign in to comment.