diff options
| author | xengineering <me@xengineering.eu> | 2023-04-15 22:44:44 +0200 | 
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2023-04-16 10:09:35 +0200 | 
| commit | a2af6617175d95fa4937b8aa38ed0bfc955085a8 (patch) | |
| tree | fc6db70deae3341de61b1087ac1e246501367868 | |
| parent | a074a9e8e92135f41b64de26df44f287e94aef47 (diff) | |
| download | limox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.tar limox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.tar.zst limox-a2af6617175d95fa4937b8aa38ed0bfc955085a8.zip | |
Implement domain part extraction in Go
This is needed to continue with DNS resolution.
| -rw-r--r-- | go/main.go | 30 | 
1 files changed, 30 insertions, 0 deletions
| @@ -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) | 
