diff --git a/internal/services/server_service.go b/internal/services/server_service.go index 5c7c569d..b1047ac2 100644 --- a/internal/services/server_service.go +++ b/internal/services/server_service.go @@ -42,6 +42,7 @@ func (s *ServerService) Info(ctx context.Context, req *proto.InfoReq) (*proto.In AllowedIps: allowedIPs(s.Config), DnsEnabled: s.Config.DNS.Enabled, DnsAddress: network.ServerVPNIP(s.Config.VPN.CIDR).IP.String(), + IsBasicProvider: strings.Contains(user.Provider, "basic"), }, nil } diff --git a/proto/proto/server.pb.go b/proto/proto/server.pb.go index 4bf46b8e..0519463a 100644 --- a/proto/proto/server.pb.go +++ b/proto/proto/server.pb.go @@ -66,6 +66,7 @@ type InfoRes struct { AllowedIps string `protobuf:"bytes,7,opt,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"` DnsEnabled bool `protobuf:"varint,8,opt,name=dns_enabled,json=dnsEnabled,proto3" json:"dns_enabled,omitempty"` DnsAddress string `protobuf:"bytes,9,opt,name=dns_address,json=dnsAddress,proto3" json:"dns_address,omitempty"` + IsBasicProvider bool `protobuf:"varint,10,opt,name=is_basic_provider,json=isBasicProvider,proto3" json:"is_basic_provider,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -159,6 +160,13 @@ func (m *InfoRes) GetDnsAddress() string { return "" } +func (m *InfoRes) GetIsBasicProvider() bool { + if m != nil { + return m.IsBasicProvider + } + return false +} + func init() { proto.RegisterType((*InfoReq)(nil), "proto.InfoReq") proto.RegisterType((*InfoRes)(nil), "proto.InfoRes") @@ -167,27 +175,28 @@ func init() { func init() { proto.RegisterFile("server.proto", fileDescriptor_ad098daeda4239f7) } var fileDescriptor_ad098daeda4239f7 = []byte{ - // 308 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xcf, 0x4e, 0xf3, 0x30, - 0x10, 0xc4, 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, 0xde, 0x4f, 0xa3, 0x6c, 0x54, 0xdc, 0x74, - 0xfc, 0x35, 0x60, 0x76, 0x07, 0x23, 0x45, 0xa5, 0x90, 0x7b, 0xa5, 0xf9, 0xc0, 0x5b, 0x86, 0x8a, - 0x96, 0xad, 0x64, 0x8f, 0x30, 0x16, 0x75, 0x6d, 0x4e, 0x28, 0x4b, 0x65, 0x89, 0x0f, 0x7d, 0x0a, - 0x5c, 0xd0, 0xca, 0x52, 0x6b, 0x90, 0x9a, 0x7e, 0x13, 0x46, 0x7e, 0x1d, 0xa4, 0xa6, 0xee, 0xf8, - 0xc5, 0x20, 0xa4, 0x74, 0x48, 0xc4, 0x93, 0x70, 0x41, 0x6a, 0x5a, 0x06, 0xb2, 0x58, 0xc0, 0x60, - 0xed, 0xbb, 0x67, 0x19, 0xc4, 0x6d, 0x85, 0xec, 0x3a, 0x74, 0x91, 0x5f, 0xba, 0x9d, 0xfc, 0xd5, - 0x34, 0xfb, 0x57, 0x0d, 0x3c, 0x78, 0xf9, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x30, 0xb0, 0x21, - 0xb6, 0x01, 0x00, 0x00, + // 335 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xcd, 0x6e, 0xea, 0x30, + 0x10, 0x85, 0x6f, 0xb8, 0xe1, 0x27, 0xc3, 0xd5, 0xfd, 0xf1, 0xca, 0x17, 0xb5, 0x34, 0x62, 0x95, + 0x76, 0x11, 0x2a, 0xfa, 0x04, 0x54, 0xea, 0x02, 0x75, 0x53, 0x05, 0x89, 0xad, 0xe5, 0x60, 0x43, + 0xad, 0x06, 0xdb, 0xf5, 0x04, 0x10, 0xcf, 0xdb, 0x17, 0xa9, 0x62, 0x27, 0x95, 0xba, 0xf2, 0x9c, + 0xcf, 0xc7, 0x73, 0xac, 0x19, 0xf8, 0x85, 0xd2, 0x9d, 0xa4, 0xc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x76, 0xcd, 0x5b, 0x03, 0x17, 0xc2, 0x49, 0x44, 0x9a, 0x84, 0x0e, 0x42, 0xe3, 0x32, 0x10, + 0x72, 0x07, 0xff, 0x14, 0xb2, 0x92, 0xa3, 0xda, 0x32, 0xeb, 0xcc, 0x49, 0x09, 0xe9, 0x28, 0x84, + 0x9f, 0x2a, 0x7c, 0x6c, 0xf8, 0x4b, 0x8b, 0x17, 0x0b, 0x18, 0xac, 0xfd, 0x9e, 0x48, 0x06, 0x71, + 0x33, 0x6e, 0xf2, 0x3b, 0xcc, 0x2d, 0x6f, 0xf7, 0x30, 0xf9, 0xae, 0x71, 0xf6, 0xa3, 0x1c, 0x78, + 0xf0, 0xf0, 0x19, 0x00, 0x00, 0xff, 0xff, 0xcf, 0xde, 0xdc, 0x10, 0xe2, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/server.proto b/proto/server.proto index 80e0ab6a..c6d08839 100644 --- a/proto/server.proto +++ b/proto/server.proto @@ -22,4 +22,5 @@ message InfoRes { string allowed_ips = 7; bool dns_enabled = 8; string dns_address = 9; + bool is_basic_provider = 10; } diff --git a/website/src/components/Navigation.tsx b/website/src/components/Navigation.tsx index a2fe582c..7637328f 100644 --- a/website/src/components/Navigation.tsx +++ b/website/src/components/Navigation.tsx @@ -17,6 +17,14 @@ const useStyles = makeStyles((theme) => ({ })); export default function Navigation() { + + function logout_basic() { + var req = new window.XMLHttpRequest() + req.open("HEAD", "/signin/0", false, "*", (new Date()).getTime().toString()) + req.send("") + document.location.href = '/signout' + } + const classes = useStyles(); const hasAuthCookie = !!getCookie('auth-session'); return ( @@ -44,7 +52,7 @@ export default function Navigation() { )} {hasAuthCookie && ( - + AppState.info?.isBasicProvider ? logout_basic() : document.location.href = '/signout'}> )} diff --git a/website/src/sdk/server_pb.ts b/website/src/sdk/server_pb.ts index 1dd8fb70..09aa3f2c 100644 --- a/website/src/sdk/server_pb.ts +++ b/website/src/sdk/server_pb.ts @@ -116,6 +116,7 @@ export declare namespace InfoRes { allowedIps: string, dnsEnabled: boolean, dnsAddress: string, + isBasicProvider: boolean, } } @@ -203,6 +204,14 @@ export class InfoRes extends jspb.Message { (jspb.Message as any).setProto3StringField(this, 9, value); } + getIsBasicProvider(): boolean { + return jspb.Message.getFieldWithDefault(this, 10, false); + } + + setIsBasicProvider(value: boolean): void { + (jspb.Message as any).setProto3BooleanField(this, 10, value); + } + serializeBinary(): Uint8Array { const writer = new jspb.BinaryWriter(); InfoRes.serializeBinaryToWriter(this, writer); @@ -220,6 +229,7 @@ export class InfoRes extends jspb.Message { allowedIps: this.getAllowedIps(), dnsEnabled: this.getDnsEnabled(), dnsAddress: this.getDnsAddress(), + isBasicProvider: this.getIsBasicProvider(), }; } @@ -261,6 +271,10 @@ export class InfoRes extends jspb.Message { if (field9.length > 0) { writer.writeString(9, field9); } + const field10 = message.getIsBasicProvider(); + if (field10 != false) { + writer.writeBool(10, field10); + } } static deserializeBinary(bytes: Uint8Array): InfoRes { @@ -313,6 +327,10 @@ export class InfoRes extends jspb.Message { const field9 = reader.readString() message.setDnsAddress(field9); break; + case 10: + const field10 = reader.readBool() + message.setIsBasicProvider(field10); + break; default: reader.skipField(); break; @@ -346,6 +364,7 @@ function InfoResFromObject(obj: InfoRes.AsObject | undefined): InfoRes | undefin message.setAllowedIps(obj.allowedIps); message.setDnsEnabled(obj.dnsEnabled); message.setDnsAddress(obj.dnsAddress); + message.setIsBasicProvider(obj.isBasicProvider); return message; }