aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/imap/imap.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 20713a4..51687ff 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -2,7 +2,9 @@ package imap
import (
"fmt"
+ "net"
"strings"
+ "time"
imapClient "github.com/emersion/go-imap/client"
@@ -10,6 +12,12 @@ import (
"github.com/Necoro/feed2imap-go/pkg/log"
)
+var dialer imapClient.Dialer
+
+func init() {
+ dialer = &net.Dialer{Timeout: 30 * time.Second}
+}
+
func newImapClient(url config.Url) (*imapClient.Client, error) {
var (
c *imapClient.Client
@@ -17,12 +25,12 @@ func newImapClient(url config.Url) (*imapClient.Client, error) {
)
if url.ForceTLS() {
- if c, err = imapClient.DialTLS(url.HostPort(), nil); err != nil {
+ if c, err = imapClient.DialWithDialerTLS(dialer, url.HostPort(), nil); err != nil {
return nil, fmt.Errorf("connecting (TLS) to %s: %w", url.Host, err)
}
log.Print("Connected to ", url.HostPort(), " (TLS)")
} else {
- if c, err = imapClient.Dial(url.HostPort()); err != nil {
+ if c, err = imapClient.DialWithDialer(dialer, url.HostPort()); err != nil {
return nil, fmt.Errorf("connecting to %s: %w", url.Host, err)
}
}
2imap-go.git/commit/internal/feed/mail.go?h=v1.5.0&id=1e62523249b9837233367bfc37a82b03243c5b9f&follow=1'>when tls verification is disabled for the feed, we should also disable this f...René 'Necoro' Neumann1-3/+4 2020-05-03Better handling of embedded images with relative urlsRené 'Necoro' Neumann1-13/+27 2020-05-03Slightly enhance loggingRené 'Necoro' Neumann1-4/+4 2020-05-03Explicit version infoRené 'Necoro' Neumann4-12/+15 2020-05-03--version flagRené 'Necoro' Neumann1-0/+6 2020-05-03Rename from 'client' to 'cl'René 'Necoro' Neumann5-26/+26 2020-05-03Use UIDPLUS Imap extensionRené 'Necoro' Neumann4-11/+33 2020-05-03Fix update in IMAPRené 'Necoro' Neumann1-2/+12 2020-05-03Update support for IMAPRené 'Necoro' Neumann5-17/+205 2020-05-03Option "reupload-if-updated"René 'Necoro' Neumann2-0/+4 2020-05-03Fix typoRené 'Necoro' Neumann1-2/+2 2020-05-02Use uuid library directly and encode to base64.René 'Necoro' Neumann6-10/+16 2020-05-02RestructureRené 'Necoro' Neumann8-95/+111 2020-05-02WIP: Message-IdsRené 'Necoro' Neumann8-5/+40 2020-05-02Typo and mention config example in READMERené 'Necoro' Neumann2-1/+3