Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
ab8515ce
Commit
ab8515ce
authored
4 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6250c7ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
20 deletions
+18
-20
go/neo/client.go
go/neo/client.go
+17
-19
go/neo/neonet/net.go
go/neo/neonet/net.go
+1
-1
No files found.
go/neo/client.go
View file @
ab8515ce
...
@@ -38,7 +38,6 @@ import (
...
@@ -38,7 +38,6 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/xzlib"
"lab.nexedi.com/kirr/neo/go/internal/xzlib"
"lab.nexedi.com/kirr/neo/go/neo/internal/xsha1"
"lab.nexedi.com/kirr/neo/go/neo/internal/xsha1"
"lab.nexedi.com/kirr/neo/go/neo/internal/xtls"
"lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
...
@@ -83,6 +82,8 @@ type Client struct {
...
@@ -83,6 +82,8 @@ type Client struct {
eventq0
[]
*
zodb
.
EventCommit
// buffer for initial messages, until .at0 is initialized
eventq0
[]
*
zodb
.
EventCommit
// buffer for initial messages, until .at0 is initialized
at0Initialized
bool
// true after .at0 is initialized
at0Initialized
bool
// true after .at0 is initialized
at0Ready
chan
(
struct
{})
// ready after .at0 is initialized
at0Ready
chan
(
struct
{})
// ready after .at0 is initialized
ownNet
bool
// true if Client "owns" networker and should release it on Close
}
}
var
_
zodb
.
IStorageDriver
=
(
*
Client
)(
nil
)
var
_
zodb
.
IStorageDriver
=
(
*
Client
)(
nil
)
...
@@ -111,11 +112,16 @@ func (cli *Client) Run(ctx context.Context) error {
...
@@ -111,11 +112,16 @@ func (cli *Client) Run(ctx context.Context) error {
return
cli
.
talkMaster
(
ctx
)
return
cli
.
talkMaster
(
ctx
)
}
}
func
(
c
*
Client
)
Close
()
error
{
func
(
c
*
Client
)
Close
()
(
err
error
)
{
c
.
talkMasterCancel
()
c
.
talkMasterCancel
()
// XXX wait talkMaster finishes -> XXX return err from that?
// XXX wait talkMaster finishes -> XXX return err from that?
// XXX what else?
// XXX what else?
return
nil
// close networker if configured to do so
if
c
.
ownNet
{
err
=
c
.
node
.
Net
.
Close
()
}
return
err
}
}
// --- connection with master ---
// --- connection with master ---
...
@@ -613,7 +619,6 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
...
@@ -613,7 +619,6 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
defer
xerr
.
Contextf
(
&
err
,
"neo: open %s"
,
u
)
defer
xerr
.
Contextf
(
&
err
,
"neo: open %s"
,
u
)
var
ssl
bool
var
ssl
bool
var
ca
,
cert
,
key
string
switch
u
.
Scheme
{
switch
u
.
Scheme
{
case
"neo"
:
ssl
=
false
case
"neo"
:
ssl
=
false
case
"neos"
:
ssl
=
true
case
"neos"
:
ssl
=
true
...
@@ -635,24 +640,21 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
...
@@ -635,24 +640,21 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
return
v
return
v
}
}
lonode
:=
xpop
(
"lonode"
,
false
)
netcfg
:=
neonet
.
Config
{}
netcfg
.
LoNode
=
xpop
(
"lonode"
,
false
)
if
!
ssl
{
if
!
ssl
{
if
len
(
x
)
!=
0
{
if
len
(
x
)
!=
0
{
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"credentials can be specified only with neos:// scheme"
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"credentials can be specified only with neos:// scheme"
)
}
}
}
else
{
}
else
{
ca
=
xpop
(
"ca"
,
true
)
netcfg
.
CA
=
xpop
(
"ca"
,
true
)
c
ert
=
xpop
(
"cert"
,
true
)
netcfg
.
C
ert
=
xpop
(
"cert"
,
true
)
k
ey
=
xpop
(
"key"
,
true
)
netcfg
.
K
ey
=
xpop
(
"key"
,
true
)
if
len
(
x
)
!=
0
{
if
len
(
x
)
!=
0
{
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"invalid credentials: %v"
,
x
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"invalid credentials: %v"
,
x
)
}
}
if
!
(
ca
!=
""
&&
cert
!=
""
&&
key
!=
""
)
{
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"incomplete ca/cert/key provided"
)
}
}
}
name
:=
u
.
Path
name
:=
u
.
Path
...
@@ -677,13 +679,9 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
...
@@ -677,13 +679,9 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"TODO write mode not implemented"
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"TODO write mode not implemented"
)
}
}
net
:=
xnet
.
NetPlain
(
"tcp"
)
// TODO not only "tcp" ?
net
,
err
:=
neonet
.
Join
(
ctx
,
netcfg
)
if
ssl
{
if
err
!=
nil
{
tlsCfg
,
err
:=
xtls
.
ConfigForP2P
(
ca
,
cert
,
key
)
return
nil
,
zodb
.
InvalidTid
,
err
if
err
!=
nil
{
return
nil
,
zodb
.
InvalidTid
,
err
}
net
=
xnet
.
NetTLS
(
net
,
tlsCfg
)
}
}
c
:=
NewClient
(
name
,
u
.
Host
,
net
)
c
:=
NewClient
(
name
,
u
.
Host
,
net
)
...
...
This diff is collapsed.
Click to expand it.
go/neo/neonet/net.go
View file @
ab8515ce
...
@@ -87,7 +87,7 @@ func Join(ctx context.Context, cfg Config) (net xnet.Networker, err error) {
...
@@ -87,7 +87,7 @@ func Join(ctx context.Context, cfg Config) (net xnet.Networker, err error) {
network
.
Close
()
// ignore err
network
.
Close
()
// ignore err
return
nil
,
err
return
nil
,
err
}
}
network
.
AutoClose
()
network
.
AutoClose
()
// host.Close will close network
net
=
host
net
=
host
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment