GODT-1901: Allow to set IMAP SSL from UI

This commit is contained in:
Leander Beernaert
2022-10-13 10:58:11 +02:00
committed by James Houlahan
parent 209c315a76
commit e10cd2a3ed
116 changed files with 3713 additions and 973 deletions

File diff suppressed because it is too large Load Diff

View File

@ -80,6 +80,8 @@ service Bridge {
rpc IsDoHEnabled(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc SetUseSslForSmtp(google.protobuf.BoolValue) returns (google.protobuf.Empty);
rpc UseSslForSmtp(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc SetUseSslForImap(google.protobuf.BoolValue) returns (google.protobuf.Empty);
rpc UseSslForImap(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc Hostname(google.protobuf.Empty) returns (google.protobuf.StringValue);
rpc ImapPort(google.protobuf.Empty) returns (google.protobuf.Int32Value);
rpc SmtpPort(google.protobuf.Empty) returns (google.protobuf.Int32Value);
@ -377,6 +379,7 @@ message MailSettingsEvent {
MailSettingsErrorEvent error = 1;
UseSslForSmtpFinishedEvent useSslForSmtpFinished = 2;
ChangePortsFinishedEvent changePortsFinished = 3;
UseSslForImapFinishedEvent useSslForImapFinished = 4;
}
}
@ -391,6 +394,8 @@ message MailSettingsErrorEvent {
message UseSslForSmtpFinishedEvent {}
message UseSslForImapFinishedEvent {}
message ChangePortsFinishedEvent {}
//**********************************************************

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.7
// - protoc v3.19.4
// source: bridge.proto
package grpc
@ -71,6 +71,8 @@ type BridgeClient interface {
IsDoHEnabled(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
SetUseSslForSmtp(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
UseSslForSmtp(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
SetUseSslForImap(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
UseSslForImap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
Hostname(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error)
ImapPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error)
SmtpPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error)
@ -478,6 +480,24 @@ func (c *bridgeClient) UseSslForSmtp(ctx context.Context, in *emptypb.Empty, opt
return out, nil
}
func (c *bridgeClient) SetUseSslForImap(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/grpc.Bridge/SetUseSslForImap", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) UseSslForImap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) {
out := new(wrapperspb.BoolValue)
err := c.cc.Invoke(ctx, "/grpc.Bridge/UseSslForImap", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) Hostname(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) {
out := new(wrapperspb.StringValue)
err := c.cc.Invoke(ctx, "/grpc.Bridge/Hostname", in, out, opts...)
@ -696,6 +716,8 @@ type BridgeServer interface {
IsDoHEnabled(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
SetUseSslForSmtp(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error)
UseSslForSmtp(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
SetUseSslForImap(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error)
UseSslForImap(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
Hostname(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error)
ImapPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error)
SmtpPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error)
@ -848,6 +870,12 @@ func (UnimplementedBridgeServer) SetUseSslForSmtp(context.Context, *wrapperspb.B
func (UnimplementedBridgeServer) UseSslForSmtp(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method UseSslForSmtp not implemented")
}
func (UnimplementedBridgeServer) SetUseSslForImap(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetUseSslForImap not implemented")
}
func (UnimplementedBridgeServer) UseSslForImap(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method UseSslForImap not implemented")
}
func (UnimplementedBridgeServer) Hostname(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method Hostname not implemented")
}
@ -1665,6 +1693,42 @@ func _Bridge_UseSslForSmtp_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler)
}
func _Bridge_SetUseSslForImap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(wrapperspb.BoolValue)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).SetUseSslForImap(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/SetUseSslForImap",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).SetUseSslForImap(ctx, req.(*wrapperspb.BoolValue))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_UseSslForImap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).UseSslForImap(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/UseSslForImap",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).UseSslForImap(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_Hostname_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
@ -2131,6 +2195,14 @@ var Bridge_ServiceDesc = grpc.ServiceDesc{
MethodName: "UseSslForSmtp",
Handler: _Bridge_UseSslForSmtp_Handler,
},
{
MethodName: "SetUseSslForImap",
Handler: _Bridge_SetUseSslForImap_Handler,
},
{
MethodName: "UseSslForImap",
Handler: _Bridge_UseSslForImap_Handler,
},
{
MethodName: "Hostname",
Handler: _Bridge_Hostname_Handler,

View File

@ -122,6 +122,10 @@ func NewMailSettingsUseSslForSmtpFinishedEvent() *StreamEvent { //nolint:revive,
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_UseSslForSmtpFinished{UseSslForSmtpFinished: &UseSslForSmtpFinishedEvent{}}})
}
func NewMailSettingsUseSslForImapFinishedEvent() *StreamEvent { //nolint:revive,stylecheck
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_UseSslForImapFinished{UseSslForImapFinished: &UseSslForImapFinishedEvent{}}})
}
func NewMailSettingsChangePortFinishedEvent() *StreamEvent {
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_ChangePortsFinished{ChangePortsFinished: &ChangePortsFinishedEvent{}}})
}

View File

@ -601,6 +601,27 @@ func (s *Service) UseSslForSmtp(ctx context.Context, _ *emptypb.Empty) (*wrapper
return wrapperspb.Bool(s.bridge.GetSMTPSSL()), nil
}
func (s *Service) SetUseSslForImap(ctx context.Context, useSsl *wrapperspb.BoolValue) (*emptypb.Empty, error) { //nolint:revive,stylecheck
s.log.WithField("useSsl", useSsl.Value).Debug("SetUseSslForImap")
if s.bridge.GetIMAPSSL() == useSsl.Value {
return &emptypb.Empty{}, nil
}
if err := s.bridge.SetIMAPSSL(useSsl.Value); err != nil {
s.log.WithError(err).Error("Failed to set IMAP SSL")
return nil, status.Errorf(codes.Internal, "failed to set IMAP SSL: %v", err)
}
return &emptypb.Empty{}, s.SendEvent(NewMailSettingsUseSslForImapFinishedEvent())
}
func (s *Service) UseSslForImap(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { //nolint:revive,stylecheck
s.log.Debug("UseSslForImap")
return wrapperspb.Bool(s.bridge.GetIMAPSSL()), nil
}
func (s *Service) Hostname(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) {
s.log.Debug("Hostname")

View File

@ -1,3 +1,20 @@
// Copyright (c) 2022 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
package grpc
/*