/* MastoGem, A Mastodon proxy for Gemini Copyright (C) 2021 Romain de Laage This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package main import ( "log" "time" ) type OriginalBlog struct { Id string `json:"id"` Author Account `json:"account"` } type Blog struct { Id string `json:"id"` Content string `json:"content"` Date string `json:"created_at"` Author Account `json:"account"` Tags []Tag `json:"tags"` Mentions []Mention `json:"mentions"` Reblog *OriginalBlog `json:"reblog"` } type Config struct { Listen string `json:"listen"` CertPath string `json:"cert_path"` KeyPath string `json:"key_path"` BaseURL string `json:"base_url"` Title string `json:"title"` HomeMessage string `json:"home_message"` RateLimit int `json:"rate_limit"` } type Account struct { Id string `json:"id"` DisplayName string `json:"display_name"` Name string `json:"acct"` Url string `json:"url"` } type Thread struct { Ancestors []Blog `json:"ancestors"` Descendants []Blog `json:"descendants"` } type Mention struct { Id string `json:"id"` Name string `json:"acct"` } type Tag struct { Name string `json:"name"` } type Rate struct { Date time.Time Count int } var rateMap map[string]Rate func main() { config := getConfig() rateMap = make(map[string]Rate) listener := listen(config.Listen, config.CertPath, config.KeyPath) log.Println("Server successfully started") log.Println("Server is listening at " + config.Listen) serve(listener, config.BaseURL, config.Title, config.HomeMessage, config.RateLimit) }