Skip to content

Commit

Permalink
Merge pull request #19 from TetAlius/release-0.1.2
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
TetAlius authored Jun 8, 2018
2 parents 42bb415 + 15c3229 commit 5316d4e
Show file tree
Hide file tree
Showing 36 changed files with 911 additions and 355 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.gitignore
.git
scripts
.nginx.conf
.ngrok.yml
.travis.yml
docker-compose.yml
Dockerfile
*.log
LICENSE
README.md
131 changes: 131 additions & 0 deletions .nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
server {
listen 80;
server_name gosyncmycalendars.me;

location ^~ /.well-known/acme-challenge {
root /usr/share/nginx/html;
default_type text/plain;
allow all;
}

location / {
rewrite ^ https://$host$request_uri? permanent;
}
}


server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name gosyncmycalendars.me;

ssl_protocols TLSv1.2 TLSv1.1 TLSv1;

ssl_certificate /etc/letsencrypt/live/gosyncmycalendars.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gosyncmycalendars.me/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/gosyncmycalendars.me/chain.pem;

#server_tokens off;

#ssl_buffer_size 8k;

#ssl_certificate /etc/ssl/certs/server.csr;
#ssl_certificate_key /etc/ssl/certs/server.key;



#ssl_dhparam /etc/ssl/certs/dhparam-2048.pem;

#ssl_prefer_server_ciphers on;

#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

#ssl_ecdh_curve secp384r1;
#ssl_session_tickets off;

# OCSP stapling
#ssl_stapling on;
#ssl_stapling_verify on;
#resolver 8.8.8.8;


location ^~ /.well-known/acme-challenge {
root /usr/share/nginx/html;
default_type text/plain;
allow all;
}

location /{
proxy_pass http://GoSyncMyCalendars-app:8080/;
#security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
#CSP
#add_header Content-Security-Policy "frame-src 'self'; default-src 'self'; script-src 'self' 'unsafe-inline' https://gosyncmycalendars.me:8081 https://maxcdn.bootstrapcdn.com https://ajax.googleapis.com; img-src 'self'; style-src 'self' https://maxcdn.bootstrapcdn.com; font-src 'self' data: https://maxcdn.bootstrapcdn.com; form-action 'self'; upgrade-insecure-requests;" always;
#add_header Referrer-Policy "strict-origin-when-cross-origin" always;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}

}


server {
listen 8081 ssl http2;
listen [::]:8081 ssl http2;
server_name gosyncmycalendars.me:8081;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/gosyncmycalendars.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gosyncmycalendars.me/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/gosyncmycalendars.me/chain.pem;

#server_tokens off;

#ssl_buffer_size 8k;

#ssl_certificate /etc/ssl/certs/server.csr;
#ssl_certificate_key /etc/ssl/certs/server.key;

#ssl_dhparam /etc/ssl/certs/dhparam-2048.pem;

#ssl_prefer_server_ciphers on;

#ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

#ssl_ecdh_curve secp384r1;
#ssl_session_tickets off;

# OCSP stapling
#ssl_stapling on;
#ssl_stapling_verify on;
#resolver 8.8.8.8;

location ^~ /.well-known/acme-challenge {
root /usr/share/nginx/html;
default_type text/plain;
allow all;
}


location /{
proxy_pass http://GoSyncMyCalendars-app:8081/;
#security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
#CSP
#add_header Content-Security-Policy "frame-src 'self'; default-src 'self'; script-src 'self' 'unsafe-inline' https://maxcdn.bootstrapcdn.com https://ajax.googleapis.com; img-src 'self'; style-src 'self' https://maxcdn.bootstrapcdn.com; font-src 'self' data: https://maxcdn.bootstrapcdn.com; form-action 'self'; upgrade-insecure-requests;" always;
#add_header Referrer-Policy "strict-origin-when-cross-origin" always;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}

}
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: go

notifications:
email:
on_success: always
on_failure: always
#notifications:
# email:
# on_success: always
# on_failure: always

go:
- 1.x
Expand Down
6 changes: 3 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type AccountManager interface {
GetInternalID() int
SetCalendars([]CalendarManager)
GetSyncCalendars() []CalendarManager
Principal() bool
}

type CalendarManager interface {
Expand All @@ -66,7 +65,7 @@ type CalendarManager interface {
SetName(string)
GetUUID() string
SetUUID(string)
CreateEmptyEvent() EventManager
CreateEmptyEvent(string) EventManager
}

type EventManager interface {
Expand All @@ -82,6 +81,7 @@ type EventManager interface {

GetRelations() []EventManager

GetUpdatedAt() (time.Time, error)
MarkWrong()
GetState() int
SetState(int)
Expand All @@ -100,8 +100,8 @@ type SubscriptionManager interface {
GetUUID() uuid.UUID
GetAccount() AccountManager
GetType() string
setTime()
GetExpirationDate() time.Time
GetResourceID() string
}

type RefreshError struct {
Expand Down
3 changes: 0 additions & 3 deletions api/google_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,3 @@ func (a *GoogleAccount) SetCalendars(calendars []CalendarManager) {
func (a *GoogleAccount) GetSyncCalendars() []CalendarManager {
return a.calendars
}
func (a *GoogleAccount) Principal() bool {
return a.principal
}
20 changes: 5 additions & 15 deletions api/google_calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import (
"github.com/TetAlius/GoSyncMyCalendars/util"
)

func RetrieveGoogleCalendar(ID string, account *GoogleAccount) *GoogleCalendar {
func RetrieveGoogleCalendar(ID string, uid string, account *GoogleAccount) *GoogleCalendar {
cal := new(GoogleCalendar)
cal.ID = ID
cal.account = account
cal.uuid = uid
return cal
}

Expand Down Expand Up @@ -203,6 +204,7 @@ func (calendar *GoogleCalendar) GetEvent(eventID string) (event EventManager, er
if err != nil {
return
}
log.Warningf("GOOGLE EVENT: %s", contents)
//TODO: this part
if eventResponse.Status != "cancelled" {
err = eventResponse.extractTime()
Expand Down Expand Up @@ -261,18 +263,6 @@ func (calendar *GoogleCalendar) SetAccount(a AccountManager) (err error) {
return
}

// There's no explicit way to renew subscription.
// One new must be created
func (calendar *GoogleCalendar) RenewSubscription(a AccountManager, subscriptionID string) (err error) {
panic("NOT YET IMPLEMENTED")
return
}

func (calendar *GoogleCalendar) DeleteSubscription(a AccountManager, subscriptionID string) (err error) {
panic("NOT YET IMPLEMENTED")
return
}

func (calendar *GoogleCalendar) GetQueryID() string {
return url.QueryEscape(calendar.GetID())
}
Expand Down Expand Up @@ -308,6 +298,6 @@ func (calendar *GoogleCalendar) GetCalendars() []CalendarManager {
return calendar.calendars
}

func (calendar *GoogleCalendar) CreateEmptyEvent() EventManager {
return &GoogleEvent{calendar: calendar}
func (calendar *GoogleCalendar) CreateEmptyEvent(ID string) EventManager {
return &GoogleEvent{ID: ID, calendar: calendar}
}
10 changes: 10 additions & 0 deletions api/google_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ func (event *GoogleEvent) GetInternalID() int {
return event.internalID
}

func (event *GoogleEvent) GetUpdatedAt() (t time.Time, err error) {
t, err = time.Parse(time.RFC3339, event.Updated)
if err != nil {
sentryClient().CaptureErrorAndWait(err, map[string]string{"api": "google"})
return
}

return t.UTC(), nil
}

func (event *GoogleEvent) extractTime() (err error) {
var start, end, format string
sentry := sentryClient()
Expand Down
7 changes: 3 additions & 4 deletions api/google_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type GoogleAccount struct {
Kind int `json:"-"`
InternID int `json:"-"`
calendars []CalendarManager `json:"-"`
principal bool `json:"-"`
}

type GoogleCalendarListResponse struct {
Expand Down Expand Up @@ -228,12 +227,12 @@ type GoogleAttachment struct {
type GoogleSubscription struct {
calendar *GoogleCalendar
ID string `json:"id"`
Type string `json:"type"`
NotificationURL string `json:"address"`
Type string `json:"type,omitempty"`
NotificationURL string `json:"address,omitempty"`
ResourceID string `json:"resourceId,omitempty"`
ResourceURI string `json:"resourceUri,omitempty"`
Token string `json:"token,omitempty"`
Expiration int64 `json:"expiration"`
Expiration int64 `json:"expiration,omitempty,string"`
Uuid uuid.UUID `json:"-"`
expirationDate time.Time
}
Expand Down
Loading

0 comments on commit 5316d4e

Please sign in to comment.