diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 7c753e6ab9231107f7c5f5b6a172122567560c51..ebaeccf199483addd2c508c412e271331b589ee3 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -234,6 +234,31 @@ public class EditBean extends IndexBean { return getProperty(tunnel, I2PTunnelHTTPClientBase.PROP_OUTPROXY_PW, ""); } + /** all of these are @since 0.8.3 */ + public String getLimitMinute(int tunnel) { + return getProperty(tunnel, PROP_MAX_CONNS_MIN, "0"); + } + + public String getLimitHour(int tunnel) { + return getProperty(tunnel, PROP_MAX_CONNS_HOUR, "0"); + } + + public String getLimitDay(int tunnel) { + return getProperty(tunnel, PROP_MAX_CONNS_DAY, "0"); + } + + public String getTotalMinute(int tunnel) { + return getProperty(tunnel, PROP_MAX_TOTAL_CONNS_MIN, "0"); + } + + public String getTotalHour(int tunnel) { + return getProperty(tunnel, PROP_MAX_TOTAL_CONNS_HOUR, "0"); + } + + public String getTotalDay(int tunnel) { + return getProperty(tunnel, PROP_MAX_TOTAL_CONNS_DAY, "0"); + } + private int getProperty(int tunnel, String prop, int def) { TunnelController tun = getController(tunnel); if (tun != null) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java index 5e38b2b4ef189e5b5b114bad3ade37ffd351899c..909e94c23ee19bf5e61e1d78c2c67423f7afaba0 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -712,6 +712,44 @@ public class IndexBean { _otherOptions.put(I2PTunnelHTTPClientBase.PROP_OUTPROXY_PW, s.trim()); } + /** all of these are @since 0.8.3 */ + protected static final String PROP_MAX_CONNS_MIN = "i2p.streaming.maxConnsPerMinute"; + protected static final String PROP_MAX_CONNS_HOUR = "i2p.streaming.maxConnsPerHour"; + protected static final String PROP_MAX_CONNS_DAY = "i2p.streaming.maxConnsPerDay"; + protected static final String PROP_MAX_TOTAL_CONNS_MIN = "i2p.streaming.maxTotalConnsPerMinute"; + protected static final String PROP_MAX_TOTAL_CONNS_HOUR = "i2p.streaming.maxTotalConnsPerHour"; + protected static final String PROP_MAX_TOTAL_CONNS_DAY = "i2p.streaming.maxTotalConnsPerDay"; + + public void setLimitMinute(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_CONNS_MIN, s.trim()); + } + + public void setLimitHour(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_CONNS_HOUR, s.trim()); + } + + public void setLimitDay(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_CONNS_DAY, s.trim()); + } + + public void setTotalMinute(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_TOTAL_CONNS_MIN, s.trim()); + } + + public void setTotalHour(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_TOTAL_CONNS_HOUR, s.trim()); + } + + public void setTotalDay(String s) { + if (s != null) + _otherOptions.put(PROP_MAX_TOTAL_CONNS_DAY, s.trim()); + } + /** params needed for hashcash and dest modification */ public void setEffort(String val) { if (val != null) { @@ -911,7 +949,9 @@ public class IndexBean { "proxyUsername", "proxyPassword", "outproxyUsername", "outproxyPassword" }; private static final String _otherServerOpts[] = { - "i2cp.reduceIdleTime", "i2cp.reduceQuantity", "i2cp.leaseSetKey", "i2cp.accessList" + "i2cp.reduceIdleTime", "i2cp.reduceQuantity", "i2cp.leaseSetKey", "i2cp.accessList", + PROP_MAX_CONNS_MIN, PROP_MAX_CONNS_HOUR, PROP_MAX_CONNS_DAY, + PROP_MAX_TOTAL_CONNS_MIN, PROP_MAX_TOTAL_CONNS_HOUR, PROP_MAX_TOTAL_CONNS_DAY }; protected static final Set _noShowSet = new HashSet(); static { diff --git a/apps/i2ptunnel/jsp/editServer.jsp b/apps/i2ptunnel/jsp/editServer.jsp index 5d36604530ce6b94747b5c2578d3a876b563cae2..4ecd93e648200eeec97a0a4a897a15f97aecad0d 100644 --- a/apps/i2ptunnel/jsp/editServer.jsp +++ b/apps/i2ptunnel/jsp/editServer.jsp @@ -368,10 +368,46 @@ <label for="accessList" accesskey="s"> <%=intl._("Access List")%>: </label> - <textarea rows="2" style="height: 4em;" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea> + <textarea rows="2" style="height: 6em;" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea> <span class="comment"><%=intl._("(Restrict to these clients only)")%></span> </div> + <div class="subdivider"> + <hr /> + </div> + + <div class="rowItem"> + <div id="optionsField" class="rowItem"> + <label><%=intl._("Inbound connection limits (0 to disable)")%><br><%=intl._("Per client")%>:</label> + </div> + <div id="portField" class="rowItem"> + <label><%=intl._("Per minute")%>:</label> + <input type="text" id="port" name="limitMinute" value="<%=editBean.getLimitMinute(curTunnel)%>" class="freetext" /> + </div> + <div id="portField" class="rowItem"> + <label><%=intl._("Per hour")%>:</label> + <input type="text" id="port" name="limitHour" value="<%=editBean.getLimitHour(curTunnel)%>" class="freetext" /> + </div> + <div id="portField" class="rowItem"> + <label><%=intl._("Per day")%>:</label> + <input type="text" id="port" name="limitDay" value="<%=editBean.getLimitDay(curTunnel)%>" class="freetext" /> + </div> + </div> + <div class="rowItem"> + <div id="optionsField" class="rowItem"> + <label><%=intl._("Total")%>:</label> + </div> + <div id="portField" class="rowItem"> + <input type="text" id="port" name="totalMinute" value="<%=editBean.getTotalMinute(curTunnel)%>" class="freetext" /> + </div> + <div id="portField" class="rowItem"> + <input type="text" id="port" name="totalHour" value="<%=editBean.getTotalHour(curTunnel)%>" class="freetext" /> + </div> + <div id="portField" class="rowItem"> + <input type="text" id="port" name="totalDay" value="<%=editBean.getTotalDay(curTunnel)%>" class="freetext" /> + </div> + </div> + <div class="subdivider"> <hr /> </div>