Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
//go:build !android
|
|
|
|
package pty
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
func openMaster() (*os.File, string, error) {
|
|
master, err := os.OpenFile("/dev/ptmx", os.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0)
|
|
if err != nil {
|
|
return nil, "", fmt.Errorf("pty: %w", err)
|
|
}
|
|
var unlock int32
|
|
if err := ioctl(master, syscall.TIOCSPTLCK, unsafe.Pointer(&unlock)); err != nil {
|
|
master.Close()
|
|
return nil, "", fmt.Errorf("pty: unlocking: %w", err)
|
|
}
|
|
var n uint32
|
|
if err := ioctl(master, syscall.TIOCGPTN, unsafe.Pointer(&n)); err != nil {
|
|
master.Close()
|
|
return nil, "", fmt.Errorf("pty: %w", err)
|
|
}
|
|
return master, "/dev/pts/" + strconv.Itoa(int(n)), nil
|
|
}
|
|
|
|
// waitReadable waits until the master has output, for a read that came back
|
|
// with EAGAIN because the os package could not make the descriptor one its
|
|
// poller waits on.
|
|
func (p *PTY) waitReadable() error {
|
|
fd := int(p.master.Fd())
|
|
var r syscall.FdSet
|
|
r.Bits[fd/64] |= 1 << (uint(fd) % 64)
|
|
for {
|
|
if _, err := syscall.Select(fd+1, &r, nil, nil, nil); err != syscall.EINTR {
|
|
return err
|
|
}
|
|
}
|
|
}
|