Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dmsghttp feature #131

Merged
merged 13 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "{build}"

stack: go 1.16.7
stack: go 1.16.10

environment:
matrix:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ This is a note for developers about the recommended tags to keep track of the ch
Dates must be YEAR-MONTH-DAY
-->
## [0.3.2] - 2021-11-24

### Added
- Add using dmsgHTTP URLs for services on skyimager by chec `use dmsgHTTP.`.
- Add dmsghttp-config.json file to builded image on `make build-skybian-img` process

## [0.3.1] - 2021-06-30
### Changed

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Values of the boot parameters are separated by `0x1F` characters. The values are
- `GW`: The gateway IP address. Only IPv4 compatible addresses are supported.
- `SS`: The passcode for the `skysocks` app (Only valid if `MD=0x01` - Visor).
- `HVS`: Delegated hypervisor public keys. (Only valid of `MD=0x01` - Visor).
- `DH`: A dmsghttp flag to use dmsghttp-config URLs on generate skywire-config file. (Only available if dmsghttp checked and selected related json file).

These values can be written by the `skyimager-gui` (provided in this repo) with user-provided options.

Expand Down
2 changes: 2 additions & 0 deletions build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ SKYWIRE_VERSION=v0.5.0

SKYWIRE_ARM64_DOWNLOAD_URL="https://github.com/skycoin/skywire/releases/download/$SKYWIRE_VERSION/skywire-$SKYWIRE_VERSION-linux-arm64.tar.gz"
SKYWIRE_ARM_DOWNLOAD_URL="https://github.com/skycoin/skywire/releases/download/$SKYWIRE_VERSION/skywire-$SKYWIRE_VERSION-linux-arm.tar.gz"

DMSGHTTP_CONFIG_URL="https://raw.githubusercontent.com/skycoin/skywire/develop/dmsghttp-config.json"
# Offset and sector size of the Armbian image for rootfs (found automatically if not set)
IMG_OFFSET="" # 8192
IMG_SECTOR="" # 512
Expand Down
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ get_skywire()
mkdir "${PARTS_SKYWIRE_DIR}/bin"
tar xvzf "${_DST}" -C "${PARTS_SKYWIRE_DIR}/bin" || return 1

info "Downloading dmsghttp-config from ${DMSGHTTP_CONFIG_URL} to ${PARTS_SKYWIRE_DIR}"
wget -c "${DMSGHTTP_CONFIG_URL}" -O "${PARTS_SKYWIRE_DIR}/dmsghttp-config.json"

info "Cleaning..."
rm -rf "${PARTS_SKYWIRE_DIR}/bin/README.md" "${PARTS_SKYWIRE_DIR}/bin/CHANGELOG.md" || return 1

Expand Down Expand Up @@ -444,6 +447,9 @@ copy_to_img()
sudo cp "$ROOT"/static/skybian-firstrun "$FS_MNT_POINT"/usr/bin/ || return 1
sudo chmod +x "$FS_MNT_POINT"/usr/bin/skybian-firstrun || return 1

# Copy dsmghttp-config.json
sudo cp "${PARTS_SKYWIRE_DIR}/dmsghttp-config.json" "${FS_MNT_POINT}"/etc/ || return 1

if [ ${BOARD} == rpi ] || [ ${BOARD} == rpi64 ] || [ ${BOARD} == rpiw ] ; then

# Copy scripts
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.16

require (
fyne.io/fyne/v2 v2.1.0
github.com/fyne-io/fyne-cross v1.1.2 // indirect
github.com/fyne-io/fyne-cross v1.1.3 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/mholt/archiver v3.1.1+incompatible
github.com/rakyll/statik v0.1.7
github.com/sirupsen/logrus v1.8.1
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/skycoin/dmsg v0.0.0-20210920120709-00d42a07e45a
github.com/skycoin/dmsg v0.0.0-20211125122021-388f2fc645c9
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/skywire v0.5.0-rc1.0.20210928121629-42a9d6fc03f1
github.com/skycoin/skywire v0.5.2-0.20211125164518-be38adb86ad3
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
)
Expand Down
31 changes: 14 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.10/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.15/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -70,10 +68,8 @@ github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3/go.mod h1:CzM2G82Q9BDUv
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fyne-io/fyne-cross v1.1.1 h1:loYNaPB7ty43owmPzyDH5jxuEPfBUx+MZ0K41LenqJc=
github.com/fyne-io/fyne-cross v1.1.1/go.mod h1:rFwn/M7pkAVZkQTndaD3i5DbZ5oTMJIEWDCF2w7d60Q=
github.com/fyne-io/fyne-cross v1.1.2 h1:LezY9vF5gLGpNoSGzB5EP0MU9D/b3F73NKafTZZnSLw=
github.com/fyne-io/fyne-cross v1.1.2/go.mod h1:rFwn/M7pkAVZkQTndaD3i5DbZ5oTMJIEWDCF2w7d60Q=
github.com/fyne-io/fyne-cross v1.1.3 h1:LT9giTMLaLt/fNmxPEOCkaHxQJNQu/utY0Ugwe1yFjw=
github.com/fyne-io/fyne-cross v1.1.3/go.mod h1:rFwn/M7pkAVZkQTndaD3i5DbZ5oTMJIEWDCF2w7d60Q=
github.com/gen2brain/dlgs v0.0.0-20210609125024-bf6c92aaa984/go.mod h1:/eFcjDXaU2THSOOqLxOPETIbHETnamk8FA/hMjhg/gU=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A=
Expand Down Expand Up @@ -210,9 +206,8 @@ github.com/marten-seemann/qtls-go1-15 v0.1.4 h1:RehYMOyRW8hPVEja1KBVsFVNSm35Jj9M
github.com/marten-seemann/qtls-go1-15 v0.1.4/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
Expand Down Expand Up @@ -312,16 +307,19 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
github.com/skycoin/dmsg v0.0.0-20210915195912-2f9b055f39fe/go.mod h1:qs+tELY7/gHRHqCK0iPp62BuYlu10OcV5zN0lpa1Scc=
github.com/skycoin/dmsg v0.0.0-20210920120709-00d42a07e45a h1:nwPsyPz33ti8ZcsJWWsbnjOZw2w2W8U2JpSQ26KHLps=
github.com/skycoin/dmsg v0.0.0-20210920120709-00d42a07e45a/go.mod h1:p9RQVoY18Rpi5mrbIfE55z7XcKTscIUiNh8nv1ou1/8=
github.com/skycoin/dmsg v0.0.0-20211007145032-962409e5845f h1:0/PJaqsGvkfuf4I/Jg2ayQq0AJg5qhIhK4YzevX72Bg=
github.com/skycoin/dmsg v0.0.0-20211007145032-962409e5845f/go.mod h1:p9RQVoY18Rpi5mrbIfE55z7XcKTscIUiNh8nv1ou1/8=
github.com/skycoin/dmsg v0.0.0-20211125122021-388f2fc645c9 h1:Cy62MJBJkPWc/zoNBnwJC7+ak+Hj20TgwxOMKkhi8mI=
github.com/skycoin/dmsg v0.0.0-20211125122021-388f2fc645c9/go.mod h1:EgRg8fy5RjF67OJlh9w+vhq3+Phyn6AXKSedkzhf1ww=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o=
github.com/skycoin/skycoin v0.26.0/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw=
github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I=
github.com/skycoin/skycoin v0.27.1/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw=
github.com/skycoin/skywire v0.5.0-rc1.0.20210928121629-42a9d6fc03f1 h1:6rqD0Q1TgiWTGF99C7lUbrComNgIBez4/tqAP2b8Mew=
github.com/skycoin/skywire v0.5.0-rc1.0.20210928121629-42a9d6fc03f1/go.mod h1:mgDMpaOFkMPt8gbCTI5VniyBsczUkvcDWdLhXRqG+Zs=
github.com/skycoin/skywire v0.5.2-0.20211124111242-1d90a0492f62 h1:rn4w5R7w+oJPfECHESeTBUBPKcMJYbmea+0nbtJ3gjY=
github.com/skycoin/skywire v0.5.2-0.20211124111242-1d90a0492f62/go.mod h1:H35tSOwurUtc25Pm2lr5vLQIm8tzrfJV92mSUb2dXvY=
github.com/skycoin/skywire v0.5.2-0.20211125164518-be38adb86ad3 h1:Tj1S6wEx3r9czfrWpqcVgonM+mWb62QTKjm89zVL4rs=
github.com/skycoin/skywire v0.5.2-0.20211125164518-be38adb86ad3/go.mod h1:rUwrKlHSt1UQQ5uyip1OXWmBejOyBOrNomXqTM+UEZA=
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f h1:A5dEM1OE9YhN3LciZU9qPjo7fJ46JeHNi3JCroDkK0Y=
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f/go.mod h1:48cleOxgkiLbgv322LOg2Vrxtu180Mb8GG1HbuhmFYM=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down Expand Up @@ -412,9 +410,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand Down Expand Up @@ -492,9 +489,9 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210608053332-aa57babbf139/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
Expand Down
4 changes: 2 additions & 2 deletions integration/cmd/mock_mbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func main() {
switch mode {
case 0:
// Hypervisor
bp, err = boot.MakeHypervisorParams(gwIP, sk, "", "")
bp, err = boot.MakeHypervisorParams(gwIP, sk, "", "", false)
case 1:
// Visor.
bp, err = boot.MakeVisorParams(gwIP, gwIP, sk, makeHvPKs(), "123456", "", "")
bp, err = boot.MakeVisorParams(gwIP, gwIP, sk, makeHvPKs(), "123456", "", "", false)
default:
err = errors.New("invalid mode")
}
Expand Down
43 changes: 32 additions & 11 deletions pkg/boot/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const (
SocksPassEnv = "SS"
WifiNameEnv = "WFN"
WifiPassEnv = "WFP"
// DSMGHTTP
DMSGHTTPEnv = "DH"
)

// Modes.
Expand Down Expand Up @@ -118,13 +120,16 @@ type Params struct {
LocalPK cipher.PubKey `json:"local_pk"` // Not actually encoded to bps.
LocalSK cipher.SecKey `json:"local_sk"`

// only on dmsghttp
DMSGHTTP string `json:"dmsghttp,omitempty"`
mrpalide marked this conversation as resolved.
Show resolved Hide resolved

// only valid if mode == "0x00" (hypervisor)
HypervisorPKs cipher.PubKeys `json:"hypervisor_pks,omitempty"`
SkysocksPasscode string `json:"skysocks_passcode,omitempty"`
}

// MakeHypervisorParams is a convenience function for creating boot parameters for a hypervisor.
func MakeHypervisorParams(gwIP net.IP, sk cipher.SecKey, wifiName, wifiPass string) (Params, error) {
func MakeHypervisorParams(gwIP net.IP, sk cipher.SecKey, wifiName, wifiPass string, dmsghttp bool) (Params, error) {
pk, err := sk.PubKey()
if err != nil {
return Params{}, err
Expand All @@ -140,6 +145,11 @@ func MakeHypervisorParams(gwIP net.IP, sk cipher.SecKey, wifiName, wifiPass stri
LocalPK: pk,
LocalSK: sk,
}

if dmsghttp {
params.DMSGHTTP = "dmsghttp"
}

if wifiName != "" || wifiPass != "" {
params.WifiEndpointName = wifiName
params.WifiEndpointPass = wifiPass
Expand All @@ -150,7 +160,7 @@ func MakeHypervisorParams(gwIP net.IP, sk cipher.SecKey, wifiName, wifiPass stri

// MakeVisorParams is a convenience function for creating boot parameters for a visor.
func MakeVisorParams(prevIP, gwIP net.IP, sk cipher.SecKey, hvPKs []cipher.PubKey,
socksPC string, wifiName, wifiPass string) (Params, error) {
socksPC, wifiName, wifiPass string, dmsghttp bool) (Params, error) {
pk, err := sk.PubKey()
if err != nil {
return Params{}, err
Expand All @@ -168,6 +178,11 @@ func MakeVisorParams(prevIP, gwIP net.IP, sk cipher.SecKey, hvPKs []cipher.PubKe
HypervisorPKs: hvPKs,
SkysocksPasscode: socksPC,
}

if dmsghttp {
params.DMSGHTTP = "dmsghttp"
}

if wifiName != "" || wifiPass != "" {
params.WifiEndpointName = wifiName
params.WifiEndpointPass = wifiPass
Expand Down Expand Up @@ -265,6 +280,12 @@ func (bp Params) PrintEnvs(w io.Writer) error {
return err
}
}
// DMSGHTTP
if len(bp.DMSGHTTP) > 0 {
if err := PrintEnv(w, DMSGHTTPEnv, bp.DMSGHTTP); err != nil {
return err
}
}
return nil
}

Expand All @@ -277,7 +298,7 @@ func (bp Params) PrintEnvs(w io.Writer) error {
func (bp Params) Encode() ([]byte, error) {
keys := bp.LocalSK[:]
toEncode := [][]byte{{byte(bp.Mode)}, bp.LocalIP, bp.GatewayIP,
[]byte(bp.SkysocksPasscode), []byte(bp.WifiEndpointName), []byte(bp.WifiEndpointPass)}
[]byte(bp.SkysocksPasscode), []byte(bp.WifiEndpointName), []byte(bp.WifiEndpointPass), []byte(bp.DMSGHTTP)}
for _, hvPK := range bp.HypervisorPKs {
keys = append(keys, hvPK[:]...)
}
Expand All @@ -294,21 +315,21 @@ func (bp Params) Encode() ([]byte, error) {

// Decode decodes the boot parameters from the given raw bytes.
func (bp *Params) Decode(raw []byte) error {
split := bytes.SplitN(raw, []byte{sep}, 7)
// 5 for a regular config, 7 for wifi-enabled config
if len(split) != 7 {
split := bytes.SplitN(raw, []byte{sep}, 8)

if len(split) != 8 {
return ErrCannotReadParams
}

bp.Mode, bp.LocalIP, bp.GatewayIP, bp.SkysocksPasscode =
Mode(split[0][0]), split[1], split[2], string(split[3])

if len(split) == 7 {
bp.WifiEndpointName = string(split[4])
bp.WifiEndpointPass = string(split[5])
}
bp.WifiEndpointName = string(split[4])
bp.WifiEndpointPass = string(split[5])

bp.DMSGHTTP = string(split[6])

keys := split[6]
keys := split[7]
keys = keys[copy(bp.LocalSK[:], keys):]
for {
var pk cipher.PubKey
Expand Down
5 changes: 3 additions & 2 deletions pkg/imager/fyne.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type FyneUI struct {
socksPC string
imgNumber int
hvImg bool
dmsghttp bool
hvPKs []cipher.PubKey
bps []boot.Params
}
Expand Down Expand Up @@ -134,7 +135,7 @@ func (fg *FyneUI) generateBPS() (string, error) {
if fg.hvImg {
visorsNumber--
hvPK, hvSK := cipher.GenerateKeyPair()
hvBps, err := boot.MakeHypervisorParams(fg.gwIP, hvSK, fg.wifiName, fg.wifiPass)
hvBps, err := boot.MakeHypervisorParams(fg.gwIP, hvSK, fg.wifiName, fg.wifiPass, fg.dmsghttp)
if err != nil {
return "", fmt.Errorf("boot_params[%d]: failed to generate for hypervisor: %v", len(bpsSlice), err)
}
Expand All @@ -144,7 +145,7 @@ func (fg *FyneUI) generateBPS() (string, error) {
}
for i := 0; i < visorsNumber; i++ {
_, vSK := cipher.GenerateKeyPair()
vBps, err := boot.MakeVisorParams(prevIP, fg.gwIP, vSK, hvPKs, fg.socksPC, fg.wifiName, fg.wifiPass)
vBps, err := boot.MakeVisorParams(prevIP, fg.gwIP, vSK, hvPKs, fg.socksPC, fg.wifiName, fg.wifiPass, fg.dmsghttp)
if err != nil {
return "", fmt.Errorf("boot_params[%d]: failed to generate for visor: %v", len(bpsSlice), err)
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/imager/fyne_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ func (fg *FyneUI) Page2() fyne.CanvasObject {
})
genHvImg.SetChecked(fg.hvImg)

useDMSGHTTP := widget.NewCheck("Use dmsgHTTP.", func(b bool) {
if b {
fg.dmsghttp = b
}
})

hvPKs := container.NewVBox()
hvPKs.Hide()
hvPKsRefresh := func() {
Expand Down Expand Up @@ -302,7 +308,7 @@ func (fg *FyneUI) Page2() fyne.CanvasObject {
wifiWidgets,
widget.NewLabel("Skysocks Passcode:"), socksPC,
widget.NewLabel("Number of images:"), imgNumber,
genHvImg, enableHvPKs, hvPKs, hvPKsAdd)
genHvImg, useDMSGHTTP, enableHvPKs, hvPKs, hvPKsAdd)
}

func (fg *FyneUI) resetPage2Values() {
Expand All @@ -312,6 +318,7 @@ func (fg *FyneUI) resetPage2Values() {
fg.socksPC = ""
fg.imgNumber = DefaultImgNumber
fg.hvImg = true
fg.dmsghttp = false
fg.hvPKs = nil
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/prepconf/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,24 @@ func generateConfig(conf Config) (*visorconfig.V1, error) {
ServerAddr: skyenv.DefaultAppSrvAddr,
BinPath: "/usr/bin/apps",
}

if bp.DMSGHTTP == "dmsghttp" {
var dmsghttpData visorconfig.DmsgHTTPServers
dmsghttpByte, err := os.ReadFile("/etc/dmsghttp-config.json")
if err != nil {
return out, nil
}
err = json.Unmarshal(dmsghttpByte, &dmsghttpData)
if err != nil {
return out, nil
}
out.Dmsg.Servers = dmsghttpData.Prod.DMSGServers
out.Dmsg.Discovery = dmsghttpData.Prod.DMSGDiscovery
out.Transport.Discovery = dmsghttpData.Prod.TransportDiscovery
out.Transport.AddressResolver = dmsghttpData.Prod.AddressResolver
out.Routing.RouteFinder = dmsghttpData.Prod.RouteFinder
out.UptimeTracker.Addr = dmsghttpData.Prod.UptimeTracker
out.Launcher.ServiceDisc = dmsghttpData.Prod.ServiceDiscovery
}
return out, nil
}
2 changes: 1 addition & 1 deletion static/skybian-firstrun
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ setup_skywire()
fi

# Obtains the following ENVs from boot params:
# MD IP GW PK SK HVS SS SUCCESS LOGFILE
# MD IP GW PK SK HVS SS DH SUCCESS LOGFILE
echo "-----BEGIN BOOT PARAMS-----"
echo "$BOOT_PARAMS"
echo "-----END BOOT PARAMS-----"
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/mattn/go-isatty/isatty_others.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/github.com/mattn/go-isatty/isatty_solaris.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/mattn/go-isatty/isatty_tcgets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading