mirror of
https://github.com/jech/galene.git
synced 2024-11-23 00:55:58 +01:00
Add method Addr to client.
This commit is contained in:
parent
ebfaeed05f
commit
ae42f388fe
4 changed files with 23 additions and 3 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -107,6 +108,10 @@ func (client *Client) Kick(id string, user *string, message string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) Addr() net.Addr {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) Joined(group, kind string) error {
|
func (client *Client) Joined(group, kind string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"hash"
|
"hash"
|
||||||
|
"net"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
|
@ -97,6 +98,7 @@ type ClientCredentials struct {
|
||||||
|
|
||||||
type Client interface {
|
type Client interface {
|
||||||
Group() *Group
|
Group() *Group
|
||||||
|
Addr() net.Addr
|
||||||
Id() string
|
Id() string
|
||||||
Username() string
|
Username() string
|
||||||
SetUsername(string)
|
SetUsername(string)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -58,6 +59,7 @@ func isWSNormalError(err error) bool {
|
||||||
|
|
||||||
type webClient struct {
|
type webClient struct {
|
||||||
group *group.Group
|
group *group.Group
|
||||||
|
addr net.Addr
|
||||||
id string
|
id string
|
||||||
username string
|
username string
|
||||||
permissions []string
|
permissions []string
|
||||||
|
@ -77,6 +79,10 @@ func (c *webClient) Group() *group.Group {
|
||||||
return c.group
|
return c.group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *webClient) Addr() net.Addr {
|
||||||
|
return c.addr
|
||||||
|
}
|
||||||
|
|
||||||
func (c *webClient) Id() string {
|
func (c *webClient) Id() string {
|
||||||
return c.id
|
return c.id
|
||||||
}
|
}
|
||||||
|
@ -818,7 +824,7 @@ func readMessage(conn *websocket.Conn, m *clientMessage) error {
|
||||||
|
|
||||||
const protocolVersion = "2"
|
const protocolVersion = "2"
|
||||||
|
|
||||||
func StartClient(conn *websocket.Conn) (err error) {
|
func StartClient(conn *websocket.Conn, addr net.Addr) (err error) {
|
||||||
var m clientMessage
|
var m clientMessage
|
||||||
|
|
||||||
err = readMessage(conn, &m)
|
err = readMessage(conn, &m)
|
||||||
|
@ -849,6 +855,7 @@ func StartClient(conn *websocket.Conn) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &webClient{
|
c := &webClient{
|
||||||
|
addr: addr,
|
||||||
id: m.Id,
|
id: m.Id,
|
||||||
actions: unbounded.New[any](),
|
actions: unbounded.New[any](),
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
|
|
|
@ -3,6 +3,7 @@ package rtpconn
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jech/galene/conn"
|
"github.com/jech/galene/conn"
|
||||||
|
@ -12,6 +13,7 @@ import (
|
||||||
|
|
||||||
type WhipClient struct {
|
type WhipClient struct {
|
||||||
group *group.Group
|
group *group.Group
|
||||||
|
addr net.Addr
|
||||||
id string
|
id string
|
||||||
token string
|
token string
|
||||||
username string
|
username string
|
||||||
|
@ -21,14 +23,18 @@ type WhipClient struct {
|
||||||
connection *rtpUpConnection
|
connection *rtpUpConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWhipClient(g *group.Group, id string, token string) *WhipClient {
|
func NewWhipClient(g *group.Group, id string, token string, addr net.Addr) *WhipClient {
|
||||||
return &WhipClient{group: g, id: id, token: token}
|
return &WhipClient{group: g, id: id, token: token, addr: addr}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *WhipClient) Group() *group.Group {
|
func (c *WhipClient) Group() *group.Group {
|
||||||
return c.group
|
return c.group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *WhipClient) Addr() net.Addr {
|
||||||
|
return c.addr
|
||||||
|
}
|
||||||
|
|
||||||
func (c *WhipClient) Id() string {
|
func (c *WhipClient) Id() string {
|
||||||
return c.id
|
return c.id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue