1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 06:35:11 +01:00

Updated host regex in gui

This commit is contained in:
dpad85 2017-02-09 14:04:07 +01:00
parent 654e4bfad3
commit e5d73eec45
2 changed files with 4 additions and 5 deletions

View file

@ -12,6 +12,7 @@ import javafx.scene.control.TextArea
import akka.pattern.ask
import fr.acinq.bitcoin.{BinaryData, MilliSatoshi, Satoshi}
import fr.acinq.eclair._
import fr.acinq.eclair.gui.utils.GUIValidators
import fr.acinq.eclair.io.Client
import fr.acinq.eclair.payment.CreatePayment
import grizzled.slf4j.Logging
@ -26,9 +27,8 @@ class Handlers(setup: Setup, trayIcon: TrayIcon) extends Logging {
import setup._
def open(hostPort: String, fundingSatoshis: Satoshi, pushMsat: MilliSatoshi) = {
val regex = "([a-fA-F0-9]+)@([a-zA-Z0-9\\.\\-_]+):([0-9]+)".r
hostPort match {
case regex(pubkey, host, port) =>
case GUIValidators.hostRegex(pubkey, host, port) =>
logger.info(s"connecting to $host:$port")
system.actorOf(Client.props(host, port.toInt, pubkey, fundingSatoshis, pushMsat, register))
case _ => {}

View file

@ -8,14 +8,13 @@ import scala.util.matching.Regex
* Created by DPA on 27/09/2016.
*/
object GUIValidators {
val hostRegex = """[0-9a-fA-F]+@[a-zA-Z0-9.]+:[0-9]{1,5}""".r
val hostRegex = """([a-fA-F0-9]+)@([a-zA-Z0-9\.\-_]+):([0-9]+)""".r
val amountRegex = """[0-9]+""".r
val paymentRequestRegex = """[a-zA-Z0-9]+:[a-zA-Z0-9]+:[a-zA-Z0-9]+""".r
val hexRegex = """[0-9a-fA-F]+""".r
/**
* Validate a field against a regex. If field does not match regex, validatorLabel is shown.
* Validate a field against a regex. If field does not match the regex, validatorLabel is shown.
*
* @param field String content of the field to validate
* @param validatorLabel JFX label associated to the field.