-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(agent,api,pkg): add VPN capability
It adds to the ShellHub's Agent the capability to connect to a ShellHub's Enterprise service, which provides a virtual private network between devices registered into the same namespace. To enable it, the ShellHub's instance must support it, and the `SHELLHUB_VPN` environmental variable must be set to `TRUE` on the ShellHub Agent startup.
- Loading branch information
1 parent
54fb229
commit 90ef28b
Showing
23 changed files
with
1,000 additions
and
14 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
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
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,64 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/shellhub-io/shellhub/pkg/envs" | ||
"github.com/sirupsen/logrus" | ||
migrate "github.com/xakep666/mongo-migrate" | ||
"go.mongodb.org/mongo-driver/bson" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
) | ||
|
||
var migration77 = migrate.Migration{ | ||
Version: 77, | ||
Description: "Adding VPN settings to namespace", | ||
Up: migrate.MigrationFunc(func(ctx context.Context, db *mongo.Database) error { | ||
logrus.WithFields(logrus.Fields{ | ||
"component": "migration", | ||
"version": 77, | ||
"action": "Up", | ||
}).Info("Applying migration") | ||
|
||
if envs.IsEnterprise() { | ||
update := bson.M{ | ||
"$set": bson.M{ | ||
"vpn": bson.M{ | ||
"enable": false, | ||
"address": bson.A{10, 0, 0, 0}, | ||
"mask": 16, | ||
}, | ||
}, | ||
} | ||
|
||
_, err := db. | ||
Collection("namespaces"). | ||
UpdateMany(ctx, bson.M{}, update) | ||
|
||
return err | ||
} | ||
|
||
return nil | ||
}), | ||
Down: migrate.MigrationFunc(func(ctx context.Context, db *mongo.Database) error { | ||
logrus.WithFields(logrus.Fields{ | ||
"component": "migration", | ||
"version": 77, | ||
"action": "Down", | ||
}).Info("Reverting migration") | ||
|
||
if envs.IsEnterprise() { | ||
update := bson.M{ | ||
"$unset": bson.M{"vpn": ""}, | ||
} | ||
|
||
_, err := db. | ||
Collection("namespaces"). | ||
UpdateMany(ctx, bson.M{}, update) | ||
|
||
return err | ||
} | ||
|
||
return nil | ||
}), | ||
} |
Oops, something went wrong.