1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-21 23:05:48 +01:00

Add method Addr to client.

This commit is contained in:
Juliusz Chroboczek 2024-04-30 18:17:00 +02:00
parent b7f9ef00b6
commit e7e8a9b555
4 changed files with 23 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"log"
"net"
"os"
"path/filepath"
"runtime"
@ -107,6 +108,10 @@ func (client *Client) Kick(id string, user *string, message string) error {
return err
}
func (client *Client) Addr() net.Addr {
return nil
}
func (client *Client) Joined(group, kind string) error {
return nil
}

View file

@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"hash"
"net"
"golang.org/x/crypto/bcrypt"
"golang.org/x/crypto/pbkdf2"
@ -111,6 +112,7 @@ type ClientCredentials struct {
type Client interface {
Group() *Group
Addr() net.Addr
Id() string
Username() string
SetUsername(string)

View file

@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"log"
"net"
"os"
"sync"
"time"
@ -58,6 +59,7 @@ func isWSNormalError(err error) bool {
type webClient struct {
group *group.Group
addr net.Addr
id string
username string
permissions []string
@ -77,6 +79,10 @@ func (c *webClient) Group() *group.Group {
return c.group
}
func (c *webClient) Addr() net.Addr {
return c.addr
}
func (c *webClient) Id() string {
return c.id
}
@ -818,7 +824,7 @@ func readMessage(conn *websocket.Conn, m *clientMessage) error {
const protocolVersion = "2"
func StartClient(conn *websocket.Conn) (err error) {
func StartClient(conn *websocket.Conn, addr net.Addr) (err error) {
var m clientMessage
err = readMessage(conn, &m)
@ -849,6 +855,7 @@ func StartClient(conn *websocket.Conn) (err error) {
}
c := &webClient{
addr: addr,
id: m.Id,
actions: unbounded.New[any](),
done: make(chan struct{}),

View file

@ -3,6 +3,7 @@ package rtpconn
import (
"context"
"errors"
"net"
"sync"
"github.com/jech/galene/conn"
@ -12,6 +13,7 @@ import (
type WhipClient struct {
group *group.Group
addr net.Addr
id string
token string
username string
@ -21,14 +23,18 @@ type WhipClient struct {
connection *rtpUpConnection
}
func NewWhipClient(g *group.Group, id string, token string) *WhipClient {
return &WhipClient{group: g, id: id, token: token}
func NewWhipClient(g *group.Group, id string, token string, addr net.Addr) *WhipClient {
return &WhipClient{group: g, id: id, token: token, addr: addr}
}
func (c *WhipClient) Group() *group.Group {
return c.group
}
func (c *WhipClient) Addr() net.Addr {
return c.addr
}
func (c *WhipClient) Id() string {
return c.id
}