join.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright © 2021 Ettore Di Giacinto <[email protected]>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 2 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program; if not, see <http://www.gnu.org/licenses/>.
  15. package cmd
  16. import (
  17. "context"
  18. "github.com/mudler/edgevpn/pkg/node"
  19. "github.com/urfave/cli"
  20. )
  21. func Start() cli.Command {
  22. return cli.Command{
  23. Name: "start",
  24. Usage: "Start the network without activating any interface",
  25. Description: `Connect over the p2p network without establishing a VPN.
  26. Useful for setting up relays or hop nodes to improve the network connectivity.`,
  27. UsageText: "edgevpn start",
  28. Flags: CommonFlags,
  29. Action: func(c *cli.Context) error {
  30. o, _, ll := cliToOpts(c)
  31. e, err := node.New(o...)
  32. if err != nil {
  33. return err
  34. }
  35. displayStart(ll)
  36. // Start the node to the network, using our ledger
  37. if err := e.Start(context.Background()); err != nil {
  38. return err
  39. }
  40. ll.Info("Joining p2p network")
  41. <-context.Background().Done()
  42. return nil
  43. },
  44. }
  45. }