fix(file-upload): fall back through parallel host fields when uploadIp is empty
User report: `upload_private_file` was failing with "private file upload host is invalid" on a fresh upload (boolFileExist=false). The OIDB call succeeded but `uploadIp` (field 60) came back empty, and we treated that single field as the only source of truth. Cross-referenced LagrangeGo's `OidbSvcTrpcTcp0xE37_800.proto` + NapCat's `Oidb.0XE37_800.ts`: the server has six parallel host slots on this response (uploadIp / uploadDomain / uploadIpList[0] / uploadHttpsDomain / uploadDns / uploadLanip). LagrangeGo + Lagrange.Core only read field 60 and would hit the same dead-end — we walk the chain instead. Also log the full slot set when we genuinely can't find a host so future reports can name which field the server actually populated. Adds two regression tests: one proves the fallback to `uploadDomain` goes to highway successfully, one proves we still throw when every slot is empty.
This commit is contained in:
3 files changed
+94
-1
No files matched your search
@@ -440,10 +440,42 @@ export async function uploadPrivateFile(
|
||||
if (!fileId) throw new Error('private file upload response missing file_id');
|
||||
|
||||
if (!upload.boolFileExist && uploadFile) {
|
||||
// The server normally returns the highway host in `uploadIp` (field
|
||||
// 60). LagrangeGo / Lagrange.Core both read that field directly with
|
||||
// no fallback. We've seen real captures where the server picks one
|
||||
// of the parallel host fields (uploadDomain / uploadIpList[0] /
|
||||
// uploadHttpsDomain / uploadDns) instead — likely a rollout
|
||||
// difference. Walk them in order rather than die with "upload host
|
||||
// is invalid" when the server gives us a perfectly usable host
|
||||
// through a different slot. The highway client uses HTTP PUT so we
|
||||
// can pair any of these with the regular `uploadPort`; we only fall
|
||||
// back to `uploadHttpsPort` if we picked the HTTPS-flavored host.
|
||||
const ipListFirst = (Array.isArray(upload.uploadIpList) && upload.uploadIpList[0])
|
||||
? upload.uploadIpList[0] : '';
|
||||
const uploadHost = (typeof upload.uploadIp === 'string' && upload.uploadIp)
|
||||
|| (typeof upload.uploadDomain === 'string' && upload.uploadDomain)
|
||||
|| (ipListFirst)
|
||||
|| (typeof upload.uploadHttpsDomain === 'string' && upload.uploadHttpsDomain)
|
||||
|| (typeof upload.uploadDns === 'string' && upload.uploadDns)
|
||||
|| '';
|
||||
const uploadPort = toInt(upload.uploadPort);
|
||||
const httpsHostUsed = !upload.uploadIp && !upload.uploadDomain && !ipListFirst
|
||||
&& typeof upload.uploadHttpsDomain === 'string' && !!upload.uploadHttpsDomain;
|
||||
const uploadPort = httpsHostUsed && toInt(upload.uploadHttpsPort) > 0
|
||||
? toInt(upload.uploadHttpsPort)
|
||||
: toInt(upload.uploadPort);
|
||||
if (!uploadHost || uploadPort <= 0) {
|
||||
// Surface every host-bearing field we know about so a user
|
||||
// hitting this can show us exactly which slot the server filled
|
||||
// (or whether it returned nothing at all — which would point at
|
||||
// a request mismatch rather than a missing decoder).
|
||||
log.warn(
|
||||
'private file upload host missing — ip=%s domain=%s ipList=%s httpsDomain=%s dns=%s lanip=%s port=%s httpsPort=%s',
|
||||
upload.uploadIp ?? '', upload.uploadDomain ?? '',
|
||||
JSON.stringify(upload.uploadIpList ?? []),
|
||||
upload.uploadHttpsDomain ?? '', upload.uploadDns ?? '',
|
||||
upload.uploadLanip ?? '', upload.uploadPort ?? 0,
|
||||
upload.uploadHttpsPort ?? 0,
|
||||
);
|
||||
throw new Error('private file upload host is invalid');
|
||||
}
|
||||
|
||||
|
||||
@@ -646,11 +646,27 @@ export interface OidbPrivateFileUploadReq {
|
||||
export interface OidbPrivateFileUploadRespBody {
|
||||
retCode?: pb<10, int_32>;
|
||||
retMsg?: pb<20, string>;
|
||||
// 30/40/50 (totalSpace/usedSpace/uploadedSize int64) intentionally
|
||||
// omitted — proton only needs fields we actually consume, and the
|
||||
// quota numbers don't drive any code path.
|
||||
uploadIp?: pb<60, string>;
|
||||
// Cross-checked against LagrangeGo `OidbSvcTrpcTcp0xE37_800.proto`
|
||||
// (fields 60-170 enumerated below) + NapCat `Oidb.0XE37_800.ts`.
|
||||
// Real server has been observed to leave `uploadIp` empty while
|
||||
// populating `uploadDomain` / `uploadIpList[0]` instead (likely a
|
||||
// server-side rollout difference). Decoding all of these lets us
|
||||
// fall through in the consumer rather than die with "upload host
|
||||
// is invalid" when the server picks a different field.
|
||||
uploadDomain?: pb<70, string>;
|
||||
uploadPort?: pb<80, uint_32>;
|
||||
uuid?: pb<90, string>;
|
||||
uploadKey?: pb<100, bytes>;
|
||||
boolFileExist?: pb<110, bool>;
|
||||
uploadIpList?: pb_repeated<130, string>;
|
||||
uploadHttpsPort?: pb<140, int_32>;
|
||||
uploadHttpsDomain?: pb<150, string>;
|
||||
uploadDns?: pb<160, string>;
|
||||
uploadLanip?: pb<170, string>;
|
||||
fileAddon?: pb<200, string>;
|
||||
mediaPlatformUploadKey?: pb<220, bytes>;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user