summaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-04-15 22:44:44 +0200
committerxengineering <me@xengineering.eu>2023-04-16 10:09:35 +0200
commita2af6617175d95fa4937b8aa38ed0bfc955085a8 (patch)
treefc6db70deae3341de61b1087ac1e246501367868 /go
parenta074a9e8e92135f41b64de26df44f287e94aef47 (diff)
downloadlimox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.tar
limox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.tar.zst
limox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.zip
Implement domain part extraction in Go
This is needed to continue with DNS resolution.
Diffstat (limited to 'go')
-rw-r--r--go/main.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/go/main.go b/go/main.go
index 18f2105..8bfb1fa 100644
--- a/go/main.go
+++ b/go/main.go
@@ -79,6 +79,7 @@ func (l *Limox) buttonCallback() {
switch l.State {
case Disconnected:
log.Println("Starting connection establishment")
+ go xmpp(l.JidEditor.Text(), l.PwdEditor.Text())
l.State = Connecting
case Connecting:
log.Println("Aborted connection establishment")
@@ -89,6 +90,35 @@ func (l *Limox) buttonCallback() {
}
}
+func xmpp(jid string, pwd string) {
+ log.Printf("JID: '%s' PWD: '%s'\n", jid, pwd)
+ log.Printf("Domain: '%s'\n", domainpart(jid))
+}
+
+// domainpart extracts the domain name from a JID / XMPP address. See
+// https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 for details.
+func domainpart(jid string) string {
+ list := []rune(jid)
+
+ for i, v := range(list) {
+ if v == '/' {
+ log.Printf("Index of / rune: %d\n", i)
+ list = list[:i]
+ break
+ }
+ }
+
+ for i, v := range(list) {
+ if v == '@' {
+ log.Printf("Index of @ rune: %d\n", i)
+ list = list[i+1:]
+ break
+ }
+ }
+
+ return string(list)
+}
+
func (l *Limox) draw(e system.FrameEvent) {
gtx := layout.NewContext(&l.Operations, e)