networking
brl 9 years ago
parent e28f599224
commit eee260576b

@ -1,10 +1,10 @@
package oz
import (
"syscall"
"github.com/op/go-logging"
"os"
"os/signal"
"syscall"
)
func ReapChildProcs(log *logging.Logger, callback func(int, syscall.WaitStatus)) chan os.Signal {

@ -1,4 +1,5 @@
package main
import (
"github.com/subgraph/oz/oz-daemon"
)

@ -1,7 +1,7 @@
package main
import "github.com/subgraph/oz/oz-init"
func main() {
ozinit.Main()
}

@ -1,12 +1,12 @@
package fs
import (
"errors"
"github.com/op/go-logging"
"io/ioutil"
"sort"
"strings"
"syscall"
"errors"
"github.com/op/go-logging"
)
func (fs *Filesystem) Cleanup() error {

@ -2,12 +2,12 @@ package fs
import (
"fmt"
"github.com/op/go-logging"
"os"
"path"
"path/filepath"
"strings"
"syscall"
"github.com/op/go-logging"
)
type MountFlag int

@ -1,13 +1,13 @@
package fs
import (
"errors"
"fmt"
"os"
"path"
"syscall"
"os/user"
"path"
"strconv"
"errors"
"syscall"
)
var basicBindDirs = []string{

@ -1,9 +1,10 @@
package ipc
import (
"reflect"
"errors"
"fmt"
"github.com/op/go-logging"
"reflect"
)
type handlerMap map[string]reflect.Value
@ -125,5 +126,3 @@ func typeCheckHandler(h interface{}) (string, error) {
}
return string(in0.Field(0).Tag), nil
}

@ -1,8 +1,9 @@
package ipc
import (
"testing"
"reflect"
"errors"
"reflect"
"testing"
)
func TestTypeCheckHandler(t *testing.T) {
@ -48,8 +49,12 @@ func TestAddHandler(t *testing.T) {
}
func TestDispatch(t *testing.T) {
type testStruct struct{ t int "tester"}
type testStruct2 struct{ t int "tester2"}
type testStruct struct {
t int "tester"
}
type testStruct2 struct {
t int "tester2"
}
count := 0
h1 := func(ts *testStruct, m *Message) error {
count += 1

@ -6,10 +6,10 @@ import (
"net"
"syscall"
"github.com/op/go-logging"
"reflect"
"fmt"
"github.com/op/go-logging"
"io"
"reflect"
)
const maxFdCount = 3
@ -216,7 +216,6 @@ func (mc *MsgConn) readMessage() (*Message, error) {
// conn.AddHandlers(fooHandler, simpleHandler)
//
func (mc *MsgConn) AddHandlers(args ...interface{}) error {
for len(args) > 0 {
if err := mc.disp.hmap.addHandler(args[0]); err != nil {
@ -272,7 +271,6 @@ func getMessageType(msg interface{}) (string, error) {
return string(t.Field(0).Tag), nil
}
func (mc *MsgConn) newBaseMessage(msgType string, msgID int, body interface{}) (*BaseMsg, error) {
bodyBytes, err := json.Marshal(body)
if err != nil {
@ -298,4 +296,3 @@ func (mc *MsgConn) sendWithFds(data []byte, fds []int) error {
_, _, err := mc.conn.WriteMsgUnix(data, oob, nil)
return err
}

@ -1,8 +1,9 @@
package ipc
import (
"testing"
"sync"
"os"
"sync"
"testing"
)
type TestMsg struct {
@ -20,7 +21,9 @@ type testServer struct {
conn *MsgConn
wg sync.WaitGroup
}
const testSocket = "@test"
var testFactory = NewMsgFactory(new(TestMsg))
func testConnect(handler func(*TestMsg, *Message) error) (*testConnection, error) {

@ -2,14 +2,12 @@ package ipc
import (
"encoding/json"
"syscall"
"errors"
"fmt"
"reflect"
"errors"
"syscall"
)
func NewMsgFactory(msgTypes ...interface{}) MsgFactory {
mf := (MsgFactory)(make(map[string]func() interface{}))
for _, mt := range msgTypes {

@ -1,7 +1,8 @@
package ipc
import (
"time"
"sync"
"time"
)
type ResponseReader interface {
@ -75,4 +76,3 @@ func (rm *responseManager) removeById(id int, klose bool) *responseWaiter{
}
return rw
}

@ -1,4 +1,5 @@
package ipc
import (
"testing"
)

@ -1,9 +1,10 @@
package daemon
import (
"github.com/subgraph/oz/ipc"
"errors"
"strconv"
"fmt"
"github.com/subgraph/oz/ipc"
"strconv"
)
func clientConnect() (*ipc.MsgConn, error) {

@ -1,6 +1,5 @@
package daemon
type Config struct {
profileDir string `json:"profile_dir"`
}

@ -5,10 +5,10 @@ import (
"github.com/op/go-logging"
"github.com/subgraph/oz"
"github.com/subgraph/oz/ipc"
"syscall"
"github.com/subgraph/oz/fs"
"github.com/subgraph/oz/ipc"
"os/user"
"syscall"
)
type daemonState struct {
@ -53,7 +53,6 @@ func initialize() *daemonState {
return d
}
func (d *daemonState) handleChildExit(pid int, wstatus syscall.WaitStatus) {
d.Debug("Child process pid=%d exited with status %d", pid, wstatus.ExitStatus())
@ -160,4 +159,3 @@ func (d *daemonState) handleLogs(logs *LogsMsg, msg *ipc.Message) error {
msg.Respond(&OkMsg{})
return nil
}

@ -1,21 +1,21 @@
package daemon
import (
"bufio"
"fmt"
"github.com/subgraph/oz"
"github.com/subgraph/oz/fs"
"os/exec"
"syscall"
"fmt"
"io"
"bufio"
"os/user"
"github.com/subgraph/oz/xpra"
"io"
"os"
"os/exec"
"os/user"
"path"
"syscall"
)
const initPath = "/usr/local/bin/oz-init"
type Sandbox struct {
daemon *daemonState
id int
@ -142,7 +142,7 @@ func (sbox *Sandbox) logLine(line string) {
func (sbox *Sandbox) getLogFunc(c byte) func(string, ...interface{}) {
log := sbox.daemon.log
switch(c) {
switch c {
case 'D':
return log.Debug
case 'I':

@ -1,12 +1,12 @@
package daemon
import (
"github.com/op/go-logging"
"github.com/subgraph/oz/ipc"
"log"
"os"
"github.com/subgraph/oz/ipc"
)
func (d *daemonState) Debug(format string, args ...interface{}) {
d.log.Debug(format, args...)
}
@ -38,9 +38,11 @@ func (d *daemonState) initializeLogging() {
}
d.installBackends()
}
var format = logging.MustStringFormatter(
"%{color}%{time:15:04:05} â–¶ %{level:.4s} %{id:03x}%{color:reset} %{message}",
)
func (d *daemonState) addBackend(be logging.Backend) {
d.backends = append(d.backends, be)
d.installBackends()

@ -1,4 +1,5 @@
package daemon
import "github.com/subgraph/oz/ipc"
const SocketName = "@oz-control"
@ -75,4 +76,3 @@ var messageFactory = ipc.NewMsgFactory(
new(LogsMsg),
new(LogData),
)

@ -1,8 +1,9 @@
package ozinit
import (
"github.com/subgraph/oz/ipc"
"errors"
"fmt"
"github.com/subgraph/oz/ipc"
)
func clientConnect(addr string) (*ipc.MsgConn, error) {
@ -64,5 +65,3 @@ func RunShell(addr, term string) (int, error) {
return 0, fmt.Errorf("Unexpected message type received: %+v", body)
}
}

@ -1,21 +1,21 @@
package ozinit
import (
"os"
"bufio"
"fmt"
"github.com/kr/pty"
"github.com/op/go-logging"
"github.com/subgraph/oz"
"github.com/subgraph/oz/fs"
"github.com/subgraph/oz/ipc"
"os/exec"
"syscall"
"github.com/op/go-logging"
"github.com/kr/pty"
"fmt"
"github.com/subgraph/oz/xpra"
"io"
"os"
"os/exec"
"os/user"
"strconv"
"io"
"bufio"
"strings"
"syscall"
)
const profileDirectory = "/var/lib/oz/cells.d"
@ -261,4 +261,3 @@ func ptyStart(c *exec.Cmd) (ptty *os.File, err error) {
func (is *initState) handleChildExit(pid int, wstatus syscall.WaitStatus) {
is.log.Debug("Child process pid=%d exited with status %d", pid, wstatus.ExitStatus())
}

@ -1,4 +1,5 @@
package ozinit
import "github.com/subgraph/oz/ipc"
type OkMsg struct {
@ -23,4 +24,3 @@ var messageFactory = ipc.NewMsgFactory(
new(PingMsg),
new(RunShellMsg),
)

@ -3,11 +3,11 @@ package main
import (
"fmt"
"github.com/codegangsta/cli"
"os"
"github.com/subgraph/oz/oz-daemon"
"strconv"
"io"
"github.com/subgraph/oz/oz-init"
"io"
"os"
"strconv"
)
func main() {
@ -41,7 +41,6 @@ func main() {
{
Name: "clean",
Action: handleClean,
},
{
Name: "logs",
@ -50,7 +49,6 @@ func main() {
cli.BoolFlag{
Name: "f",
},
},
},
}
@ -130,7 +128,6 @@ func handleShell(c *cli.Context) {
fmt.Println("done..")
}
func getSandboxById(id int) (*daemon.SandboxInfo, error) {
sboxes, err := daemon.ListSandboxes()
if err != nil {

@ -1,10 +1,11 @@
package main
import (
"syscall"
"unsafe"
"fmt"
"os"
"os/signal"
"fmt"
"syscall"
"unsafe"
)
type winsize struct {

@ -1,9 +1,10 @@
package xpra
import (
"github.com/subgraph/oz"
"fmt"
"os"
"github.com/op/go-logging"
"github.com/subgraph/oz"
"os"
"os/exec"
"syscall"
)

@ -1,7 +1,8 @@
package xpra
import (
"github.com/subgraph/oz"
"fmt"
"github.com/subgraph/oz"
"os"
"os/exec"
)
@ -37,4 +38,3 @@ func prepareServerArgs(config *oz.XServerConf, display uint64, workdir string) [
)
return args
}

@ -1,7 +1,8 @@
package xpra
import (
"os/exec"
"github.com/subgraph/oz"
"os/exec"
)
type Xpra struct {
@ -18,7 +19,6 @@ type Xpra struct {
// Arguments passed to xpra command
xpraArgs []string
}
var xpraDefaultArgs = []string{
@ -52,4 +52,3 @@ func getDefaultArgs(config *oz.XServerConf) []string {
return args
}

Loading…
Cancel
Save