Commit eb3b0105 authored by Mygod's avatar Mygod

Fix 'Fix #1064'

parent 17bedaff
......@@ -88,10 +88,9 @@ class Acl {
override def toString: String = {
val result = new StringBuilder()
result.append(if (bypass) "[bypass_all]\n" else "[proxy_all]\n")
var bypassList = bypassHostnames.toStream
var proxyList = proxyHostnames.toStream
if (bypass) proxyList = subnets.toStream.map(_.toString) #::: bypassList
else bypassList = subnets.toStream.map(_.toString) #::: proxyList
val (bypassList, proxyList) =
if (bypass) (bypassHostnames.toStream, subnets.toStream.map(_.toString) #::: proxyHostnames.toStream)
else (subnets.toStream.map(_.toString) #::: bypassHostnames.toStream, proxyHostnames.toStream)
if (bypassList.nonEmpty) {
result.append("[bypass_list]\n")
result.append(bypassList.mkString("\n"))
......
......@@ -208,13 +208,15 @@ class CustomRulesFragment extends ToolbarFragment with Toolbar.OnMenuItemClickLi
def getSectionTitle(i: Int): String = {
val j = i - acl.subnets.size
try (if (j < 0) acl.subnets(i).address.getHostAddress.substring(0, 1) else {
val hostname = acl.proxyHostnames(i)
PATTERN_DOMAIN.findFirstMatchIn(hostname) match {
case Some(m) => m.matched.replaceAll("\\\\.", ".") // don't convert IDN yet
case None => hostname
}
}).substring(0, 1) catch {
try {
(if (j < 0) acl.subnets(i).address.getHostAddress.substring(0, 1) else {
val hostname = acl.proxyHostnames(i)
PATTERN_DOMAIN.findFirstMatchIn(hostname) match {
case Some(m) => m.matched.replaceAll("\\\\.", ".") // don't convert IDN yet
case None => hostname
}
}).substring(0, 1)
} catch {
case _: IndexOutOfBoundsException => " "
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment