ClientId is now a string instead of an int.
This commit is contained in:
parent
68804761bf
commit
86535683fa
@ -93,7 +93,7 @@ func main() {
|
||||
state.Agents = append(state.Agents, agent)
|
||||
client := models.Client{
|
||||
PublicId: "c1",
|
||||
ClientId: 3,
|
||||
ClientId: "3",
|
||||
StartTime: time.Now().In(japan),
|
||||
SessionType: "sftp",
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package comms
|
||||
import (
|
||||
"converge/pkg/support/websocketutil"
|
||||
"net"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type AgentListener struct {
|
||||
@ -42,7 +41,7 @@ func (listener AgentListener) Accept() (net.Conn, error) {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
}
|
||||
return NewLocalAddrHackConn(conn, strconv.Itoa(clientInfo.ClientId)), nil
|
||||
return NewLocalAddrHackConn(conn, clientInfo.ClientId), nil
|
||||
}
|
||||
|
||||
func (listener AgentListener) Close() error {
|
||||
|
@ -25,7 +25,7 @@ type AgentInfo struct {
|
||||
}
|
||||
|
||||
type ClientInfo struct {
|
||||
ClientId int
|
||||
ClientId string
|
||||
}
|
||||
|
||||
type SessionInfo struct {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
type Client struct {
|
||||
PublicId string
|
||||
ClientId int
|
||||
ClientId string
|
||||
StartTime time.Time
|
||||
SessionType string
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func NewClient(publicId string, clientConn iowrappers2.ReadWriteAddrCloser,
|
||||
return &ClientConnection{
|
||||
Client: models.Client{
|
||||
PublicId: publicId,
|
||||
ClientId: clientIdGenerator.IncrementAndGet(),
|
||||
ClientId: strconv.Itoa(clientIdGenerator.IncrementAndGet()),
|
||||
StartTime: time.Now(),
|
||||
},
|
||||
agent: agentConn,
|
||||
@ -107,7 +107,7 @@ func (admin *Admin) logStatus() {
|
||||
lines = append(lines, fmt.Sprintf(format, "CLIENT", "AGENT", "ACTIVE_SINCE", "REMOTE_ADDRESS", "SESSION_TYPE"))
|
||||
for _, client := range admin.clients {
|
||||
lines = append(lines, fmt.Sprintf(format,
|
||||
strconv.Itoa(client.ClientId),
|
||||
client.ClientId,
|
||||
client.PublicId,
|
||||
client.StartTime.Format(time.DateTime),
|
||||
client.client.RemoteAddr(),
|
||||
@ -248,7 +248,7 @@ func (admin *Admin) RemoveClient(client *ClientConnection) error {
|
||||
admin.mutex.Lock()
|
||||
defer admin.mutex.Unlock()
|
||||
|
||||
log.Printf("Removing client: '%d' created at %s\n", client.ClientId,
|
||||
log.Printf("Removing client: '%s' created at %s\n", client.ClientId,
|
||||
client.StartTime.Format(time.DateTime))
|
||||
// try to explicitly close connection to the agent.
|
||||
_ = client.agent.Close()
|
||||
@ -293,7 +293,7 @@ func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser) error {
|
||||
for _, client := range admin.clients {
|
||||
// a bit hacky. There should be at most one client that has an unset session
|
||||
// Very unlikely for multiple sessions to start at the same point in time.
|
||||
if strconv.Itoa(client.ClientId) == session.ClientId {
|
||||
if client.ClientId == session.ClientId {
|
||||
client.SessionType = session.SessionType
|
||||
break
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package templates
|
||||
|
||||
import (
|
||||
"converge/pkg/models"
|
||||
"strconv"
|
||||
"time"
|
||||
_ "time/tzdata"
|
||||
)
|
||||
@ -75,7 +74,7 @@ templ State(state *models.State, location *time.Location) {
|
||||
</thead>
|
||||
for _, client := range state.Clients {
|
||||
<tr>
|
||||
<td>{strconv.Itoa(client.ClientId)}</td>
|
||||
<td>{client.ClientId}</td>
|
||||
<td>{client.StartTime.In(location).Format(time.DateTime)}</td>
|
||||
<td>{client.SessionType}</td>
|
||||
<td>{client.PublicId}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user