Apply make fmt
This commit is contained in:
parent
d8eda81e0e
commit
3702fc3acb
11 changed files with 96 additions and 100 deletions
|
@ -39,17 +39,17 @@ type TorObfs4StateResource struct{}
|
|||
|
||||
// TorObfs4StateResourceModel describes the resource data model.
|
||||
type TorObfs4StateResourceModel struct {
|
||||
Id types.String `tfsdk:"id"`
|
||||
RsaIdentityPrivateKey types.String `tfsdk:"rsa_identity_private_key"`
|
||||
Id types.String `tfsdk:"id"`
|
||||
RsaIdentityPrivateKey types.String `tfsdk:"rsa_identity_private_key"`
|
||||
Ed25519IdentityPrivateKey types.String `tfsdk:"ed25519_identity_private_key"`
|
||||
NodeId types.String `tfsdk:"node_id"`
|
||||
PrivateKey types.String `tfsdk:"private_key"`
|
||||
PublicKey types.String `tfsdk:"public_key"`
|
||||
DrbgSeed types.String `tfsdk:"drbg_seed"`
|
||||
IatMode types.Int64 `tfsdk:"iat_mode"`
|
||||
Certificate types.String `tfsdk:"certificate"`
|
||||
StateJson types.String `tfsdk:"state_json"`
|
||||
BridgeLine types.String `tfsdk:"bridge_line"`
|
||||
NodeId types.String `tfsdk:"node_id"`
|
||||
PrivateKey types.String `tfsdk:"private_key"`
|
||||
PublicKey types.String `tfsdk:"public_key"`
|
||||
DrbgSeed types.String `tfsdk:"drbg_seed"`
|
||||
IatMode types.Int64 `tfsdk:"iat_mode"`
|
||||
Certificate types.String `tfsdk:"certificate"`
|
||||
StateJson types.String `tfsdk:"state_json"`
|
||||
BridgeLine types.String `tfsdk:"bridge_line"`
|
||||
}
|
||||
|
||||
// obfs4StateJson represents the JSON structure for the state file
|
||||
|
@ -164,7 +164,7 @@ func (r *TorObfs4StateResource) Create(ctx context.Context, req resource.CreateR
|
|||
// Generate obfs4 state
|
||||
err := r.generateObfs4State(ctx, &data)
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("obfs4 State Generation Error",
|
||||
resp.Diagnostics.AddError("obfs4 State Generation Error",
|
||||
fmt.Sprintf("Unable to generate obfs4 state: %s", err))
|
||||
return
|
||||
}
|
||||
|
@ -260,7 +260,6 @@ func (r *TorObfs4StateResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
tflog.Trace(ctx, "deleted obfs4 state resource")
|
||||
}
|
||||
|
||||
|
||||
// generateObfs4State generates all the obfs4 state fields
|
||||
func (r *TorObfs4StateResource) generateObfs4State(ctx context.Context, data *TorObfs4StateResourceModel) error {
|
||||
// Derive node ID from RSA identity key (required)
|
||||
|
@ -318,7 +317,7 @@ func (r *TorObfs4StateResource) generateCertificate(nodeIdHex, publicKeyHex stri
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("failed to decode node ID: %w", err)
|
||||
}
|
||||
|
||||
|
||||
publicKeyBytes, err := hex.DecodeString(publicKeyHex)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to decode public key: %w", err)
|
||||
|
@ -340,7 +339,7 @@ func (r *TorObfs4StateResource) generateCertificate(nodeIdHex, publicKeyHex stri
|
|||
// Base64 encode and remove padding
|
||||
cert := base64.StdEncoding.EncodeToString(certBytes)
|
||||
cert = strings.TrimSuffix(cert, "==")
|
||||
|
||||
|
||||
return cert, nil
|
||||
}
|
||||
|
||||
|
@ -367,8 +366,8 @@ func (r *TorObfs4StateResource) generateBridgeLine(certificate string, iatMode i
|
|||
// Use placeholder values that users can easily replace
|
||||
placeholderIP := "<IP:PORT>"
|
||||
placeholderFingerprint := "<FINGERPRINT>"
|
||||
|
||||
return fmt.Sprintf("Bridge obfs4 %s %s cert=%s iat-mode=%d",
|
||||
|
||||
return fmt.Sprintf("Bridge obfs4 %s %s cert=%s iat-mode=%d",
|
||||
placeholderIP, placeholderFingerprint, certificate, iatMode)
|
||||
}
|
||||
|
||||
|
@ -414,7 +413,7 @@ func (r *TorObfs4StateResource) deriveNodeIdFromRsaKey(rsaPrivateKeyPem string)
|
|||
|
||||
// Generate SHA1 hash of public key (this is the relay fingerprint/node ID)
|
||||
hash := sha1.Sum(publicKeyBytes)
|
||||
|
||||
|
||||
// Create node ID from the first 20 bytes (which is all of SHA1)
|
||||
nodeId, err := ntor.NewNodeID(hash[:])
|
||||
if err != nil {
|
||||
|
@ -422,4 +421,4 @@ func (r *TorObfs4StateResource) deriveNodeIdFromRsaKey(rsaPrivateKeyPem string)
|
|||
}
|
||||
|
||||
return nodeId, nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue