Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 09189af

Browse files
committed
comment out unused code
1 parent 3aa0b74 commit 09189af

File tree

2 files changed

+79
-85
lines changed

2 files changed

+79
-85
lines changed

platform/licensing/license_manager.go

Lines changed: 66 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33
package licensing
44

55
import (
6-
"bytes"
76
"fmt"
8-
"github.com/goccy/go-json"
9-
"io"
10-
"net/http"
11-
"time"
127
)
138

14-
const (
15-
obtainLicenseEndpoint = "https://licensing.quesma.com/api/license/obtain"
16-
verifyLicenseEndpoint = "https://licensing.quesma.com/api/license/verify"
17-
)
9+
//const (
10+
// obtainLicenseEndpoint = "https://licensing.quesma.com/api/license/obtain"
11+
// verifyLicenseEndpoint = "https://licensing.quesma.com/api/license/verify"
12+
//)
1813

1914
type InstallationIDPayload struct {
2015
InstallationID string `json:"installation_id"`
@@ -25,31 +20,31 @@ type LicensePayload struct {
2520
}
2621

2722
// obtainLicenseKey presents an InstallationId to the license server and receives a LicenseKey in return
28-
func (l *LicenseModule) obtainLicenseKey() (err error) {
29-
l.logDebug("Obtaining license key for installation ID [%s]", l.InstallationID)
30-
var payloadBytes []byte
31-
if payloadBytes, err = json.Marshal(InstallationIDPayload{InstallationID: l.InstallationID}); err != nil {
32-
return err
33-
}
34-
resp, err := http.Post(obtainLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
35-
if err != nil {
36-
return err
37-
}
38-
defer resp.Body.Close()
39-
40-
body, err := io.ReadAll(resp.Body)
41-
if err != nil {
42-
return err
43-
}
44-
45-
var licenseResponse LicensePayload
46-
if err = json.Unmarshal(body, &licenseResponse); err != nil {
47-
return err
48-
}
49-
l.LicenseKey = []byte(licenseResponse.LicenseKey)
50-
fmt.Printf("License key obtained and set successfully, key=[%s.....%s]\n", string(l.LicenseKey[:8]), string(l.LicenseKey[len(l.LicenseKey)-8:]))
51-
return nil
52-
}
23+
//func (l *LicenseModule) obtainLicenseKey() (err error) {
24+
// l.logDebug("Obtaining license key for installation ID [%s]", l.InstallationID)
25+
// var payloadBytes []byte
26+
// if payloadBytes, err = json.Marshal(InstallationIDPayload{InstallationID: l.InstallationID}); err != nil {
27+
// return err
28+
// }
29+
// resp, err := http.Post(obtainLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
30+
// if err != nil {
31+
// return err
32+
// }
33+
// defer resp.Body.Close()
34+
//
35+
// body, err := io.ReadAll(resp.Body)
36+
// if err != nil {
37+
// return err
38+
// }
39+
//
40+
// var licenseResponse LicensePayload
41+
// if err = json.Unmarshal(body, &licenseResponse); err != nil {
42+
// return err
43+
// }
44+
// l.LicenseKey = []byte(licenseResponse.LicenseKey)
45+
// fmt.Printf("License key obtained and set successfully, key=[%s.....%s]\n", string(l.LicenseKey[:8]), string(l.LicenseKey[len(l.LicenseKey)-8:]))
46+
// return nil
47+
//}
5348

5449
func FormatLicenseKey(licenseKey []byte) string {
5550
if len(licenseKey) < 8 { // too short to be obfuscated, most probably it's invalid anyway
@@ -59,41 +54,41 @@ func FormatLicenseKey(licenseKey []byte) string {
5954
}
6055

6156
// processLicense presents the license to the license server and receives an AllowList in return
62-
func (l *LicenseModule) processLicense() error {
63-
if fetchedLicense, err := l.fetchLicense(); err != nil {
64-
return fmt.Errorf("license validation failed with: %v", err)
65-
} else {
66-
l.License = fetchedLicense
67-
l.logDebug("Allowlist loaded successfully")
68-
l.logDebug("%s", fetchedLicense.String())
69-
}
70-
if l.License.ExpirationDate.Before(time.Now()) {
71-
return fmt.Errorf("license expired on %s", l.License.ExpirationDate)
72-
}
73-
return nil
74-
}
57+
//func (l *LicenseModule) processLicense() error {
58+
// if fetchedLicense, err := l.fetchLicense(); err != nil {
59+
// return fmt.Errorf("license validation failed with: %v", err)
60+
// } else {
61+
// l.License = fetchedLicense
62+
// l.logDebug("Allowlist loaded successfully")
63+
// l.logDebug("%s", fetchedLicense.String())
64+
// }
65+
// if l.License.ExpirationDate.Before(time.Now()) {
66+
// return fmt.Errorf("license expired on %s", l.License.ExpirationDate)
67+
// }
68+
// return nil
69+
//}
7570

76-
func (l *LicenseModule) fetchLicense() (a *License, err error) {
77-
var payloadBytes []byte
78-
if payloadBytes, err = json.Marshal(LicensePayload{LicenseKey: string(l.LicenseKey)}); err != nil {
79-
return nil, err
80-
}
81-
resp, err := http.Post(verifyLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
82-
if resp.StatusCode == http.StatusUnauthorized {
83-
return nil, fmt.Errorf("license key rejected by the License server")
84-
}
85-
if err != nil {
86-
return nil, err
87-
}
88-
defer resp.Body.Close()
89-
body, err := io.ReadAll(resp.Body)
90-
if err != nil {
91-
return nil, err
92-
}
93-
94-
if err = json.Unmarshal(body, &a); err != nil {
95-
return nil, err
96-
} else {
97-
return a, nil
98-
}
99-
}
71+
//func (l *LicenseModule) fetchLicense() (a *License, err error) {
72+
// var payloadBytes []byte
73+
// if payloadBytes, err = json.Marshal(LicensePayload{LicenseKey: string(l.LicenseKey)}); err != nil {
74+
// return nil, err
75+
// }
76+
// resp, err := http.Post(verifyLicenseEndpoint, "application/json", bytes.NewReader(payloadBytes))
77+
// if resp.StatusCode == http.StatusUnauthorized {
78+
// return nil, fmt.Errorf("license key rejected by the License server")
79+
// }
80+
// if err != nil {
81+
// return nil, err
82+
// }
83+
// defer resp.Body.Close()
84+
// body, err := io.ReadAll(resp.Body)
85+
// if err != nil {
86+
// return nil, err
87+
// }
88+
//
89+
// if err = json.Unmarshal(body, &a); err != nil {
90+
// return nil, err
91+
// } else {
92+
// return a, nil
93+
// }
94+
//}

platform/licensing/runner.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/google/uuid"
1111
"github.com/rs/zerolog"
1212
"os"
13-
"slices"
1413
)
1514

1615
type LicenseModule struct {
@@ -79,19 +78,19 @@ func (l *LicenseModule) Run() {
7978
//}
8079
}
8180

82-
func (l *LicenseModule) validateConfig() error {
83-
// Check if connectors are allowed
84-
for _, conn := range l.Config.Connectors {
85-
// TODO remove this once hydrolix connector is fully integrated
86-
if conn.ConnectorType == "hydrolix" {
87-
continue
88-
}
89-
if !slices.Contains(l.License.Connectors, conn.ConnectorType) {
90-
return fmt.Errorf("connector of type [%s] is not allowed within the current license", conn.ConnectorType)
91-
}
92-
}
93-
return nil
94-
}
81+
//func (l *LicenseModule) validateConfig() error {
82+
// // Check if connectors are allowed
83+
// for _, conn := range l.Config.Connectors {
84+
// // TODO remove this once hydrolix connector is fully integrated
85+
// if conn.ConnectorType == "hydrolix" {
86+
// continue
87+
// }
88+
// if !slices.Contains(l.License.Connectors, conn.ConnectorType) {
89+
// return fmt.Errorf("connector of type [%s] is not allowed within the current license", conn.ConnectorType)
90+
// }
91+
// }
92+
// return nil
93+
//}
9594

9695
func (l *LicenseModule) setInstallationID() {
9796
if l.Config.InstallationId != "" {

0 commit comments

Comments
 (0)