-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge decentralized cpud to cpud (#237)
* mv init.go to init_linux.go Signed-off-by: Ronald G Minnich <[email protected]> * remove decpud/init.go Signed-off-by: Ronald G Minnich <[email protected]> * move main_darwin.go to cpud Signed-off-by: Ronald G Minnich <[email protected]> * add information about mdns to cpuddo Signed-off-by: Ronald G Minnich <[email protected]> * add mdns tests Signed-off-by: Ronald G Minnich <[email protected]> * remove remnants of decpud it is now integrated and enabled with build tags. Signed-off-by: Ronald G Minnich <[email protected]> * cpud: add mdns server code intended to be enabled by build tags. Signed-off-by: Ronald G Minnich <[email protected]> * cpuddoc: add docs for ds switches Signed-off-by: Ronald G Minnich <[email protected]> * cpud: add code for mdns Signed-off-by: Ronald G Minnich <[email protected]> * add tests Signed-off-by: Ronald G Minnich <[email protected]> * cpud/serve_mdns_test.go: remove duplicate there are no mDNS tests, turns out Signed-off-by: Ronald G Minnich <[email protected]> * cpud: mv main.go to main_linux.go Signed-off-by: Ronald G Minnich <[email protected]> * cpud :add modifier, which greatly reduces the extra code needed for mDNS Signed-off-by: Ronald G Minnich <[email protected]> * remove decpud from Makefile Signed-off-by: Ronald G Minnich <[email protected]> * fix Dockerfile Signed-off-by: Ronald G Minnich <[email protected]> * cpud: don't defer Unregister We'll need to figure out how to do this properly. With this change, the mDNS service *almost* works. cpud side (note that we can run more than one cpud. So on this machine we are using sidecore to get in, then running cpud with port 17011. Nice huh?) root@192:~/go/src/github.com/u-root/cpu/cmds/decpu# ./decpu -d -sp 17011 -key ~/.ssh/cpu_rsa 1970/01/01 01:12:12 Advertising w/dnssd map[] 1970/01/01 01:12:12 starting dns-sd server 1970/01/01 01:12:12 Advertising: ._ncpu._tcp.local. client: ./decpu -sp 17011 -key ~/.ssh/cpu_rsa date Note: it seems to be ignoring the key switch in cpud. Signed-off-by: Ronald G Minnich <[email protected]> --------- Signed-off-by: Ronald G Minnich <[email protected]>
- Loading branch information
Showing
15 changed files
with
146 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2018-2019 the u-root Authors. All rights reserved | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build mDNS | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"strconv" | ||
|
||
// We use this ssh because it implements port redirection. | ||
// It can not, however, unpack password-protected keys yet. | ||
"github.com/gliderlabs/ssh" | ||
"github.com/u-root/cpu/ds" | ||
) | ||
|
||
var ( | ||
dsEnabled = flag.Bool("dnssd", true, "advertise service using DNSSD") | ||
dsInstance = flag.String("dsInstance", "", "DNSSD instance name") | ||
dsDomain = flag.String("dsDomain", "local", "DNSSD domain") | ||
dsService = flag.String("dsService", "_ncpu._tcp", "DNSSD Service Type") | ||
dsInterface = flag.String("dsInterface", "", "DNSSD Interface") | ||
dsTxtStr = flag.String("dsTxt", "", "DNSSD key-value pair string parameterizing advertisement") | ||
dsTxt map[string]string | ||
) | ||
|
||
func init() { | ||
modifiers = append(modifiers, &modifier{f: servemDNS, name: "mDNS"}) | ||
} | ||
|
||
type handleWrapper struct { | ||
handle func(s ssh.Session) | ||
} | ||
|
||
func (w *handleWrapper) handler(s ssh.Session) { | ||
ds.Tenant(1) | ||
w.handle(s) | ||
ds.Tenant(-1) | ||
} | ||
|
||
// servemDNS wraps an existing ssh session with an mDNS instance. | ||
func servemDNS(s *ssh.Server) error { | ||
if *debug { | ||
ds.Verbose(log.Printf) | ||
} | ||
dsTxt = ds.ParseKv(*dsTxtStr) | ||
|
||
v("Advertising w/dnssd %q", dsTxt) | ||
p, err := strconv.Atoi(*port) | ||
if err != nil { | ||
return fmt.Errorf("Could not parse port: %s, %w", *port, err) | ||
} | ||
|
||
err = ds.Register(*dsInstance, *dsDomain, *dsService, *dsInterface, p, dsTxt) | ||
if err != nil { | ||
return fmt.Errorf("Could not advertise with dns-sd: %w", err) | ||
} | ||
// defer ds.Unregister() | ||
|
||
wrap := &handleWrapper{ | ||
handle: s.Handler, | ||
} | ||
s.Handler = wrap.handler | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build mDNS | ||
// +build mDNS | ||
|
||
package main | ||
|
||
// Add tests here for mDNS |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.