Skip to content

Commit 13e6e9d

Browse files
committed
delete dummy test println | fix services issue with connect to dmsg
1 parent 8974118 commit 13e6e9d

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

pkg/dmsg/entity_common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,15 @@ func (c *EntityCommon) updateClientEntryLoop(ctx context.Context, done chan stru
295295
}
296296
}
297297

298-
func (c *EntityCommon) entryProtocol(ctx context.Context, pk cipher.PubKey) (string, error) {
298+
func (c *EntityCommon) entryProtocol(ctx context.Context, pk cipher.PubKey) string {
299299
entry, err := c.dc.Entry(ctx, pk)
300300
if err != nil {
301-
c.log.Debug("Entry not found.")
302-
return "", err
301+
c.log.WithField("entry", entry).Warn("Entry not found, so return empty as protocol.\n")
302+
return ""
303303
}
304304

305305
c.log.WithField("entry", entry).Debug("Entry's protocol fetch.\n")
306-
return entry.Protocol, nil
306+
return entry.Protocol
307307
}
308308

309309
func (c *EntityCommon) delEntry(ctx context.Context) (err error) {

pkg/dmsg/server.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,8 @@ func (s *Server) handleSession(conn net.Conn) {
225225
log.WithError(dSes.Close()).Info("Stopped session.")
226226
}()
227227
// detect visor protocol for dmsg
228-
protocol, err := s.entryProtocol(ctx, dSes.RemotePK())
229-
if err != nil {
230-
if err := conn.Close(); err != nil {
231-
log.WithError(err).Warn("On entryProtocol() failure, close connection resulted in error.")
232-
}
233-
cancel()
234-
return
235-
}
228+
protocol := s.entryProtocol(ctx, dSes.RemotePK())
229+
236230
// based on protocol, create smux or yamux stream session
237231
if protocol == "smux" {
238232
dSes.sm.smux, err = smux.Server(conn, smux.DefaultConfig())

pkg/dmsg/server_session.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ func (ss *ServerSession) forwardRequest(req StreamRequest) (mStr io.ReadWriteClo
197197
Debugf("After forwardRequest failed, the yamux stream is closed.")
198198
}
199199
}()
200-
fmt.Println("here 1")
201200
if ss.sm.smux != nil {
202201
if mStr, err = ss.sm.smux.OpenStream(); err != nil {
203202
return nil, nil, err
@@ -207,24 +206,18 @@ func (ss *ServerSession) forwardRequest(req StreamRequest) (mStr io.ReadWriteClo
207206
return nil, nil, err
208207
}
209208
}
210-
211-
fmt.Println("here 2")
212209
if err = ss.writeObject(mStr, req.raw); err != nil {
213210
return nil, nil, err
214211
}
215-
fmt.Println("here 3")
216212
if respObj, err = ss.readObject(mStr); err != nil {
217213
return nil, nil, err
218214
}
219-
fmt.Println("here 4")
220215
var resp StreamResponse
221216
if resp, err = respObj.ObtainStreamResponse(); err != nil {
222217
return nil, nil, err
223218
}
224-
fmt.Println("here 5")
225219
if err = resp.Verify(req); err != nil {
226220
return nil, nil, err
227221
}
228-
fmt.Println("here 6")
229222
return mStr, respObj, nil
230223
}

0 commit comments

Comments
 (0)